Function to export bytea data from database to a directory - Mailing list pgsql-admin

From Terry Khatri
Subject Function to export bytea data from database to a directory
Date
Msg-id CANH4f+jDjcC6rwNPqgoo0qNSHsCdhcOFjaO0VK6EOwDyT4K37Q@mail.gmail.com
Whole thread Raw
List pgsql-admin
Hi
The following function import Images to the database however I wan reverse of it i.e. taking the image out to a directory, I tried to reverse but can not get it right, can some be kind enough to do that for me !!
Many thanks
Terry
 
[code]
 
create or replace function bytea_import(p_path text, p_result out bytea)
                   language plpgsql as $$
declare
  l_oid oid;
  r record;
begin
  p_result := '';
  select lo_import(p_path) into l_oid;
  for r in ( select data
             from pg_largeobject
             where loid = l_oid
             order by pageno ) loop
    p_result = p_result || r.data;
  end loop;
  perform lo_unlink(l_oid);
end;$$;
[/code]

pgsql-admin by date:

Previous
From: Andrew Krause
Date:
Subject: Re: Wal archive way behind in streaming replication
Next
From: Devrim Gündüz
Date:
Subject: Re: which slony to start?