i am working wit h PostgreSQL 9 for an application, i have a database with a table 'species' where i store fish species details along with the image of the species. the table is
CREATE TABLE fishes
(
fishes character varying(7) NOT NULL,
speciesimages oid,
CONSTRAINT species_pkey PRIMARY KEY (species)
)
WITH (
OIDS=TRUE
);
i use
INSERT INTO species(fishes,fishesimages VALUES('01',lo_import('C://01.jpg'));
To store the images in the database.
to retrieve the images i use
SELECT lo_export(fishes.fishesimages,'c://outimage.jpg')
FROM fishes
WHERE fishes= '01';
This works fine when the host is Localhost but when it is the server i cannot use the path c:// as this may not exist on the server system and i dont have permissions anyways.
so i set out to use
\COPY
like this
"C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h 192.168.1.101 -p 5432 -d myDB -U DB_admin -c "\COPY (SELECT lo_export(fishes.fishesimages,'01.jpg') FROM fishes WHERE species = '01') TO 'C://leeImage.jpeg' WITH BINARY";
but this create a image file but when i open it its invalid image

can anyone tell me how to use lo_export function from the server machine and create the image on client machine?