pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14493: psql command : Unable to use set with \copy
2+ messages / 2 participants
[nested] [flat]

* BUG #14493: psql command : Unable to use set with \copy
@ 2017-01-12 09:47 maxandreogeret@gmail.com
  2017-01-12 15:26 ` Re: BUG #14493: psql command : Unable to use set with \copy Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: maxandreogeret@gmail.com @ 2017-01-12 09:47 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14493
Logged by:          Maxandre Ogeret
Email address:      maxandreogeret@gmail.com
PostgreSQL version: 9.4.1
Operating system:   Redhat
Description:        

Hello.

When launching a .sql file from batch script with psql command you can't
pass a variable with set.

batch file :
parameter=$1

psql -h XXX -U XXX -d XXX $@ --set foo=$parameter


SQL file :
\COPY ( SELECT * FROM table where id = :'foo') TO 'out.lst' WITH DELIMITER
AS '|' NULL AS 'ISNULL';

This won't work. but \qecho :'foo'

Will work.

Thanks for your reading.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #14493: psql command : Unable to use set with \copy
  2017-01-12 09:47 BUG #14493: psql command : Unable to use set with \copy maxandreogeret@gmail.com
@ 2017-01-12 15:26 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2017-01-12 15:26 UTC (permalink / raw)
  To: maxandreogeret@gmail.com; +Cc: pgsql-bugs

maxandreogeret@gmail.com writes:
> When launching a .sql file from batch script with psql command you can't
> pass a variable with set.

I think the actual issue here has nothing to do with batch files;
rather the problem is that \copy doesn't expand potential variable
references in its arguments.  I'm not sure about the compatibility
implications of changing that.  In the meantime, perhaps you could
use COPY instead of \copy.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-01-12 15:26 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-01-12 09:47 BUG #14493: psql command : Unable to use set with \copy maxandreogeret@gmail.com
2017-01-12 15:26 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox