Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am working on an application using delphi 7 as the front end and postgres 9.0 as the back end.

I have to upload images to the server so i use \lo_import and \lo_export for inserting images on the server and geting the images from the server.

i had come across a problem where is needed the LASTOID after a \lo_import so i can use the OID to update a row in my table but i cant set the syntax correct in windows

here is my question on stackoverflow.com.. i have got the answer but the script is in linux sheel command ..i cannot run it in windows

         psql -h -p 5432 -d myDB -U my_admin << EOF
         \lo_import '/path/to/my/file/zzz4.jpg'
         UPDATE species
         SET    speciesimages = :LASTOID
         WHERE  species = 'ACAAC04';


  echo "\lo_import '/path/to/my/file/zzz4.jpg' \\\\ UPDATE species SET speciesimages =   :LASTOID WHERE  species = 'ACAAC04';" | \
 psql -h -p 5432 -d myDB -U my_admin

i have tried this though in windows

  "C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h -p 5432 -d myDB -U my_admin -c "\lo_import 'C://im/zzz4.jpg'"; 

then immediately (programmatically) im doing

    "C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h -p 5432 -d nansis -U nansis_admin -c " update species SET speciesimages = :LASTOID WHERE species='ACAAC24'" 

But i get Syntax error at or near ":"

can any1 tell tell me how to covert it to windows commnad?

share|improve this question

closed as off topic by Michael Mrozek Mar 21 '12 at 13:49

Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 0 down vote accepted

I got this answer from my question on stackoverflow postgres-9-0-linux-command-to-windows-command-conversion

Just put the commands in a file (say import.psql)

 -- contents of import.psql
\lo_import '/path/to/my/file/zzz4.jpg'
 UPDATE species
 SET    speciesimages = :LASTOID
 WHERE  species = 'ACAAC04';

then issue command

 "C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h -p 5432 -d myDB -U my_admin -f import.psql
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.