psql command line variables are unknown when -c SQL statement are executed

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: psql command line variables are unknown when -c SQL statement are executed
Date: 2009-11-16 09:19:13
Message-ID: 162867790911160119o4e1ce19foc97dc393fb5640c0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

wrong:

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

good (workaround):
[pavel(at)nemesis ~]$ echo 'select :x' | psql postgres -v x=10
?column?
──────────
10
(1 row)

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

Regards
Pavel Stehule

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2009-11-16 11:23:58 Re: psql command line variables are unknown when -c SQL statement are executed
Previous Message Heikki Linnakangas 2009-11-16 09:04:27 Multixact and prepared transactions