From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Syntax error when combining --set and --command has me stumped
Date: Thu, 28 Jul 2022 14:40:06 -0500
Message-ID: <352ceea1-029d-726e-89b5-74be4946e67b@gmail.com> (raw)
$ alias psql12
alias psql12='/usr/lib/postgresql/12/bin/psql -p5433'
This works ask expected:
$ psql12 --set num=42 -ac "\echo :num"
echo :num
42
And so does this:
$ psql12 --set num=42
psql (12.11 (Ubuntu 12.11-1.pgdg18.04+1))
Type "help" for help.
postgres=# select :num;
?column?
----------
42
(1 row)
But trying to use a variable (both with and without single quotes) in a
--command statement other than "\echo" throws a syntax error at the colon:
$ psql12 --set num=42 -ac "select :num;"
select :num;
ERROR: syntax error at or near ":"
LINE 1: select :num;
^
$ psql12 --set num=42 -ac "select :'num';"
select :'num';
ERROR: syntax error at or near ":"
LINE 1: select :'num';
^
What secret sauce am I missing to get this to work?
--
Angular momentum makes the world go 'round.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: Syntax error when combining --set and --command has me stumped
In-Reply-To: <352ceea1-029d-726e-89b5-74be4946e67b@gmail.com>
References: <352ceea1-029d-726e-89b5-74be4946e67b@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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