Convert OID to Bytea


/ Published in: SQL
Save to your folder(s)

Convert an oid value into a bytea value.


Copy this code and paste it in your HTML
  1. CREATE OR REPLACE FUNCTION merge_oid(val oid)
  2. RETURNS bytea AS $$
  3. DECLARE merged bytea;
  4. DECLARE arr bytea;
  5. BEGIN
  6. FOR arr IN SELECT DATA FROM pg_largeobject WHERE loid = val ORDER BY pageno LOOP
  7. IF merged IS NULL THEN
  8. merged := arr;
  9. ELSE
  10. merged := merged || arr;
  11. END IF;
  12. END LOOP;
  13. RETURN merged;
  14.  
  15. END
  16. $$ LANGUAGE plpgsql;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.