Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIDr9-00D13R-Q4 for pgsql-novice@arkaria.postgresql.org; Mon, 02 Dec 2024 21:21:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tIDr7-003gPr-1f for pgsql-novice@arkaria.postgresql.org; Mon, 02 Dec 2024 21:21:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIDr6-003gP9-NE for pgsql-novice@lists.postgresql.org; Mon, 02 Dec 2024 21:21:21 +0000 Received: from smtp-outbound6.duck.com ([20.67.221.11]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIDr5-000iRI-2z for pgsql-novice@lists.postgresql.org; Mon, 02 Dec 2024 21:21:21 +0000 MIME-Version: 1.0 Subject: Re: Command Line option misunderstanding References: <487DB217-EA37-4139-AB97-B61B04ECAEA7.1@smtp-inbound1.duck.com> <493C622D-D3B6-4662-A617-EBCCDE5AA4DF.1@smtp-inbound1.duck.com> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Bar: - X-Rspamd-Report: MIME_GOOD(-0.1) R_SPF_ALLOW(-0.2) ARC_ALLOW(-1) X-Rspamd-Score: -1.3 X-Rspamd-Action: no action To: Laurenz Albe , punch-hassle-guise@duck.com, "pgsql-novice@lists.postgresql.org" Received: by smtp-inbound1.duck.com; Mon, 02 Dec 2024 16:21:18 -0500 Message-ID: Date: Mon, 02 Dec 2024 16:21:18 -0500 From: punch-hassle-guise@duck.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duck.com; h=From: Date: Message-ID: To: Content-Transfer-Encoding: Content-Type: Content-Language: References: Subject: MIME-Version; q=dns/txt; s=postal-KpyQVw; t=1733174478; bh=J9Lv2FEaZaI+GRuDg8mZMFjrCeYNUKJGAe9MaCXlT2o=; b=EjOO0pUFTatzbvQihqArCuqIu1k8rSpCJvPT1Ese8ogA620SanXGZNdCtvexMrslorlUKIhTi QbFppekwqeJbVNfAPBfQmSbPZshsp1XyyZuQEgYUJ0UtpU/YaQbWBAJ1yIjYrcKwPKo+4GSLut8 49XLC//2xo5FXjzAdrou9Qo= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/2/24 15:13, Laurenz Albe wrote: > 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 As the beginning of this thread shows, I know how to do this with a HERE document, I was just trying to clean it up. I am not trying to be contentious, but a simple search shows that every major implementation of SQL allows variables and there are hundreds if not thousands of pages dedicated to the idea of using variables in SQL and how they are fundamental. There are certainly reasons this doesn't work, but saying variables are psql specific...... Regards, Ken