psql command line variables are unknown when -c SQL statement are executed - Mailing list pgsql-bugs

From Pavel Stehule
Subject psql command line variables are unknown when -c SQL statement are executed
Date
Msg-id 162867790911160119o4e1ce19foc97dc393fb5640c0@mail.gmail.com
Whole thread Raw
Responses Re: psql command line variables are unknown when -c SQL statement are executed  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-bugs
wrong:

pavel@nemesis ~]$ psql postgres -v x=3D10 -c "select :x"
ERROR:  syntax error at or near ":"
LINE 1: select :x
               ^

good (workaround):
[pavel@nemesis ~]$ echo 'select :x' | psql postgres -v x=3D10
 ?column?
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80
       10
(1 row)

psql have to have process external variables first and then execute query.

Regards
Pavel Stehule

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Multixact and prepared transactions
Next
From: Peter Eisentraut
Date:
Subject: Re: psql command line variables are unknown when -c SQL statement are executed