public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: [email protected]
To: [email protected]
Subject: Re: Command Line option misunderstanding
Date: Mon, 02 Dec 2024 21:13:28 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On Mon, 2024-12-02 at 13:47 -0500, [email protected] 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





reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Command Line option misunderstanding
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox