Re: Command Line option misunderstanding

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: punch-hassle-guise(at)duck(dot)com, pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: Command Line option misunderstanding
Date: 2024-12-02 20:13:28
Message-ID: cd1068a8f07f98936bc2964dc7c22c109191801b.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, 2024-12-02 at 13:47 -0500, punch-hassle-guise(at)duck(dot)com wrote:
> psql -h anna -d GT7 -v v1=12 -c 'select :v1'
>
> autocommit on
>
> ERROR:  syntax error at or near ":"
> LINE 1: select :v1

The documentation says:

-c command
--command=command

[...]

command must be either a command string that is completely parsable by the server
(i.e., it contains no psql-specific features), or a single backslash command.

Now variables are definitely a psql-specific feature, so variable substitution
won't work. Use a here document!

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David G. Johnston 2024-12-02 20:36:11 Re: Command Line option misunderstanding
Previous Message Joe Conway 2024-12-02 20:12:34 Re: Command Line option misunderstanding