Thread: Send parameters using Shell script to PostgreSQL
Hi.... I'm new using PostgreSQL, and I trying to run a script of shell where I can send parameters to a sentence COPY but always returned an error. This is my sentence in SHELL, where insertar_usuario_archivo.sql contain this sentence SQL: \COPY T_SADCDMA_USUARIO_AAA from :v_archivo WITH DELIMITER '|'; and file.cargar contain only the data who I whant put inside the BD whith the delimiter "|". $postgrelhome/bin/64/psql -w -h 192.168.85.50 -p 5432 -U aprn_des -f /export/home/sso/LOADER_SADCDMA/insertar_usuario_archivo.sql -v v_archivo='/export/home/sso/LOADER_SADCDMA/file.cargar' -d PGSQL_DES This is the error that returned me when I run the sentence: psql:/export/home/sso/LOADER_SADCDMA/insertar_usuario_archivo.sql:2: :v_archivo: No such file or directory -- View this message in context: http://postgresql.1045698.n5.nabble.com/Send-parameters-using-Shell-script-to-PostgreSQL-tp3319655p3319655.html Sent from the PostgreSQL - novice mailing list archive at Nabble.com.
On Monday 27 December 2010 21:41:48 wolfang wrote: > Hi.... > > I'm new using PostgreSQL, and I trying to run a script of shell where I can > send parameters to a sentence COPY but always returned an error. > > This is my sentence in SHELL, where insertar_usuario_archivo.sql contain > this sentence SQL: \COPY T_SADCDMA_USUARIO_AAA from :v_archivo WITH > DELIMITER '|'; > > and file.cargar contain only the data who I whant put inside the BD whith > the delimiter "|". > > $postgrelhome/bin/64/psql -w -h 192.168.85.50 -p 5432 -U aprn_des -f > /export/home/sso/LOADER_SADCDMA/insertar_usuario_archivo.sql -v > v_archivo='/export/home/sso/LOADER_SADCDMA/file.cargar' -d PGSQL_DES > > This is the error that returned me when I run the sentence: > > psql:/export/home/sso/LOADER_SADCDMA/insertar_usuario_archivo.sql:2: > :v_archivo: No such file or directory > Hi, I think your v_archivo='/export/home/sso/LOADER_SADCDMA/file.cargar' should be v_archivo="'/export/home/sso/LOADER_SADCDMA/file.cargar'" ie. the single quoted value 'path/to/file' surrounded by double quotes. BR, Aarni -- Aarni Ruuhimäki -------------- This is a bug-free broadcast from Ubuntu 9.10 Karmic Koala Linux System PROUD TO BE 100% Microsoft FREE!
Thanks Aarni but I tried with double quote and have the same result, returned to me the same message of error. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Send-parameters-using-Shell-script-to-PostgreSQL-tp3319655p3320288.html Sent from the PostgreSQL - novice mailing list archive at Nabble.com.
On Tuesday 28 December 2010 16:03:16 wolfang wrote: > Thanks Aarni but I tried with double quote and have the same result, > returned to me the same message of error. > Hi Wolfgang, I tried this ok on Pg8.3: [postgres@kymicentos ~]$/usr/local/pgsql/bin/psql -f test_insert.sql -v v_archivo="'/home/postgres/test_insert.txt'" -d test_x My test_insert.sql has a single line and a command: COPY persons FROM :v_archivo WITH DELIMITER '|'; So is your path right and the file really exists? BR, Aarni -- Aarni Ruuhimäki -------------- This is a bug-free broadcast from Ubuntu 9.10 Karmic Koala Linux System PROUD TO BE 100% Microsoft FREE!
Let me do some change. I don't have that version, I have the previous one and may be the problem. I will change the version to 8.3 and then do the test. $ psql -V psql (PostgreSQL) 8.1.11 contains support for command-line editing I hope solve all the problems... After the change, I do the test and I write you for let you know the result. Regards -- View this message in context: http://postgresql.1045698.n5.nabble.com/Send-parameters-using-Shell-script-to-PostgreSQL-tp3319655p3320432.html Sent from the PostgreSQL - novice mailing list archive at Nabble.com.