Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oH9Ml-00065o-OG for pgsql-general@arkaria.postgresql.org; Thu, 28 Jul 2022 19:40:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oH9Mi-0004Nm-RG for pgsql-general@arkaria.postgresql.org; Thu, 28 Jul 2022 19:40:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oH9Mi-0004Nd-Ef for pgsql-general@lists.postgresql.org; Thu, 28 Jul 2022 19:40:12 +0000 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oH9Mg-0000uq-6z for pgsql-general@lists.postgresql.org; Thu, 28 Jul 2022 19:40:11 +0000 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1013ecaf7e0so3505653fac.13 for ; Thu, 28 Jul 2022 12:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:to:content-language:from :subject:content-transfer-encoding; bh=x9LhIKEtESf7nqqlwc3im54LozO7apUipNPss7nspH8=; b=bcjCjE23ZvVIv5/QGinR8GQGo49yoBX4qxFaqM/g81wshMCyOdXuGl+ad6zhB4B+i/ u5QK0tWMa10E148WIBT2A7T6Zhk/zSPiSKuDQ2AWAYtYl6dnR9MKlljQ9riQ+VihNWZM VeOE4QHSBJjDQigvFp87LWXJBLXaH4a5ziVi6tOblhIFyl1vnlznvSpyCbgprsPfcY9u FvW+60/4AuLzTrALMbAUhVxVWoT1Xkd4ZpR3Plj49fWUZngYqMgGsfxnd1jVO1tpuSEH ifjEQDvQArnNkvoL5++RIMeu1gLe1nmkHzxcrM9esEXlv8TNJCEFdISLG6jm7bRb3+WC 46lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:to :content-language:from:subject:content-transfer-encoding; bh=x9LhIKEtESf7nqqlwc3im54LozO7apUipNPss7nspH8=; b=Jk0ec69AeVUIRg+EIwZTYS3HYthfJPKe/A7sEHJYpjxw9TXlIkdLOeLy1mkEwIuKV3 onkCLmgipVEvIX1TZVHl9JJoYqw91W3Z1nIgZIFno+S0sGS5J9njf5QSYCeJhkUSU4ta 5k3hJ87PZwmyRQuIDD3oSx4Pse2v0zcvBIeYMs16gidKP9A2sWRe3w4jygSre9m6DVxk eiuJAI/XetP5EJztOgu6EMyxxf80TAyQngtFy2KZPQ0kve5uhT6OTD3ukJ3bv3CUZhdM qJVLkQ5MgLFzZxTzwNvNCTlXAc9Mh6lu6+KIPinTffDhFo7QtOKpXwuVbWQcyhksW8Va iFJw== X-Gm-Message-State: AJIora9g6I05P5ytwuFAORLvx6rZsa07i33rT28VCbRQ8rizDf+r0czH rfKRPCkYb+XwrU+ZRaNyIEoCbUJZqoY= X-Google-Smtp-Source: AGRyM1vlWUmLkBW8cuQXa1qDiDEs+bNethSiGrjlmgtIb/5OPkjBtOTzxAu/PezVyjnfTNSSK/MTYA== X-Received: by 2002:a05:6870:64a8:b0:10d:cb0e:5ced with SMTP id cz40-20020a05687064a800b0010dcb0e5cedmr72574oab.259.1659037207645; Thu, 28 Jul 2022 12:40:07 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id bx6-20020a0568081b0600b0033a6bfdc5adsm587123oib.36.2022.07.28.12.40.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Jul 2022 12:40:07 -0700 (PDT) Message-ID: <352ceea1-029d-726e-89b5-74be4946e67b@gmail.com> Date: Thu, 28 Jul 2022 14:40:06 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 To: pgsql-general@lists.postgresql.org Content-Language: en-US From: Ron Subject: Syntax error when combining --set and --command has me stumped Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk $ 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.