| From: | Terry Khatri <terrykhatri531(at)gmail(dot)com> |
|---|---|
| To: | pgsql-admin(at)postgresql(dot)org |
| Cc: | terrykhatri531(at)gmail(dot)com |
| Subject: | Function to export bytea data from database to a directory |
| Date: | 2014-06-24 15:40:50 |
| Message-ID: | CANH4f+jDjcC6rwNPqgoo0qNSHsCdhcOFjaO0VK6EOwDyT4K37Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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]
| From | Date | Subject | |
|---|---|---|---|
| Next Message | John Scalia | 2014-06-24 18:19:37 | Fwd: Re: Wal archive way behind in streaming replication |
| Previous Message | John Scalia | 2014-06-23 14:24:14 | Wal archive way behind in streaming replication |