Re: Command Line option misunderstanding - Mailing list pgsql-novice

From Laurenz Albe
Subject Re: Command Line option misunderstanding
Date
Msg-id cd1068a8f07f98936bc2964dc7c22c109191801b.camel@cybertec.at
Whole thread Raw
In response to Command Line option misunderstanding  (punch-hassle-guise@duck.com)
List pgsql-novice
On Mon, 2024-12-02 at 13:47 -0500, punch-hassle-guise@duck.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



pgsql-novice by date:

Previous
From: Joe Conway
Date:
Subject: Re: Command Line option misunderstanding
Next
From: "David G. Johnston"
Date:
Subject: Re: Command Line option misunderstanding