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