From: | Erwin Brandstetter <brsaweda(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Import file into bytea field in SQL/plpgsql? |
Date: | 2008-03-05 00:53:57 |
Message-ID: | 3617a52e-9930-49fd-a254-861b42ab847e@u69g2000hse.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
What I want to do:
Import a file from the file system into a bytea field of a table.
I know how to do it with large objects:
INSERT INTO mytable(oid_fld) VALUES (lo_import('/mypath/myfile'));
And export from there:
SELECT lo_export(oid_fld, '/mypath/myfile2') FROM mytable WHERE
<some condition>;
Now, I could copy over from pg_largeobject:
INSERT INTO mytable(bytea_fld) SELECT data FROM pg_largeobject
WHERE loid = 1234567;
And create a large object and export from there as above.
But that seems unnecessarily complex, and .. well .. stupid.
There must be a simpler way to import/export a file (as a whole, an
image for instance) into/out of my bytea field - in SQL or plpgsql?
Probably another set of functions I overlooked?
Thanks in advance
Erwin
From | Date | Subject | |
---|---|---|---|
Next Message | Chris | 2008-03-05 04:25:31 | Re: I don't understand this WARNING on pg_ctl startup |
Previous Message | Luis Alberto Pérez Paz | 2008-03-05 00:40:32 | PGPOOL_HA |