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 1sb2kO-00DPGU-0g for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2024 18:47:56 +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 1sb2jM-00F3lH-N6 for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2024 18:46:52 +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 1sb2jM-00F3l8-7R for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2024 18:46:52 +0000 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sb2jF-003L7T-Cg for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2024 18:46:51 +0000 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-39b3c36d3adso7025525ab.1 for ; Mon, 05 Aug 2024 11:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail-com.20230601.gappssmtp.com; s=20230601; t=1722883603; x=1723488403; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=tHfZEPsSXXxMSa0iatZP6HBnl8GAffB0zbtTgnyyRzE=; b=L+HgJeVcJYxw+g3zeCjUbku9QHSPNcuqSS4cjGX/hfEgQx776VI+O4X3paXow1RrdY 8i7GhTmugjdMM11Aqm9LnpFBVpEgwovI7/uN/Pv4yjRhF6QB1TdPd8/1BvKZR22mrpAw 8/oyOXmqkpl5WEtz9AGNj6kiRv0z8eV+tTgpEqHdlvqPT476o5D39oVRFiivpiI1APro kdL581GcLsLUWH97uuqjxn92QqPoaJ1QNEGGcoomudTAhPEVCg759NaNpGWRMlsrHi/Y DNiNn30SeoGUxkIClI38vYZV9HVwHiTNyGWsvtbb3OkB7dcdneN35ReyGB7afhfFtKO1 RZcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722883603; x=1723488403; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tHfZEPsSXXxMSa0iatZP6HBnl8GAffB0zbtTgnyyRzE=; b=e1eb2xP6hLf+5tWeL86dhvrUS8VZuo3Ae2eEThrybP9x6MRCmmDv569IHIsj+21Xqj UdhC5ClIOVqX8lxWfXFApGhk9nPMuYzra45KFra89p3DhrkjTb+DYGpGImZ5RdnXJkVr 2fnZZjb3MLrCLOUrUUWF8J0SdW8SSLey3bM8inf+sTmVBEXIo7kQ6wGXIbtvk1LOc0GJ DbKwyIODvZpuAOpvnA84D8XPQuzR/pOQiIEYEyus7cpvelwQ4y7jLjFm3YD11OZ2J8NP EVFkkpcukzH1UN9zx3RWo+nu7Sw8VvHjIVl7v1222wMTvZt1CjyQy+Cr7ef1LMxDEOpX A0ew== X-Gm-Message-State: AOJu0YzszQH3RfCGOawNsLtGMQcRZtiEVB+QggTODQu+rwqwg81uvES3 WRL31Enhg6ZIy7Rlf6b75++zNeCjRHckBXnSjuqQO9c0it+452mB5CBXv3y/VYiKEMz1E5tdNCd MfZfM4M0mpRFbw/WogIImY7Gjb9Q49ncM X-Google-Smtp-Source: AGHT+IFIMjnIOdumxOp2p3Nhi4vaC9NpLZVvL+Fj2lYUo8z8Gk7At5fSDy3gMb43iGWiNkto+tGX4INB+VXrNqIB8MM= X-Received: by 2002:a92:6909:0:b0:39a:12d7:2841 with SMTP id e9e14a558f8ab-39b1fb87912mr124030035ab.15.1722883603012; Mon, 05 Aug 2024 11:46:43 -0700 (PDT) MIME-Version: 1.0 From: Wiwwo Staff Date: Mon, 5 Aug 2024 18:46:06 +0000 Message-ID: Subject: Check psql parameter is passed, if not ask for it To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000025a50b061ef41901" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000025a50b061ef41901 Content-Type: text/plain; charset="UTF-8" Hi! I want to check if I pass the parameter "param1" to a sql script "delme.sql" like ``` \if ':param1' \echo :param1; \else \prompt 'Param1? ' :param1 \endif select :'param1'; ``` if parameter `param1` is not passed, the .sql should ask for it. If I run something like `psql -f delme.sql -v param1=1` it works, but if i pass `psql -f delme.sql -v param1=meh` i receive `psql:delme.sql:1: error: unrecognized value ":param1" for "\if expression": Boolean expected` How can I implement that? TIA, Wiwwo --00000000000025a50b061ef41901 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!
I want to check if I pass the parameter &qu= ot;param1" to a sql script "delme.sql" like
```
=
\if ':param1'
=C2=A0 \echo :param1;
\else
=C2=A0 = \prompt 'Param1? ' :param1
\endif
select :'param1';
```
if parameter `param1` is not passed, the .sql should ask= for it.

If I run something like
`psql -= f delme.sql -v param1=3D1`
it works, but if i pass
`psql -= f delme.sql -v param1=3Dmeh`
i receive
`psql:delme.sql= :1: error: unrecognized value ":param1" for "\if expression&= quot;: Boolean expected`

How can I implement that?
TIA, Wiwwo
--00000000000025a50b061ef41901--