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 1s2w0w-007XYW-Py for pgsql-sql@arkaria.postgresql.org; Fri, 03 May 2024 16:44:02 +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 1s2w0s-00Ai74-PQ for pgsql-sql@arkaria.postgresql.org; Fri, 03 May 2024 16:43:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s2w0s-00Ai6w-EY for pgsql-sql@lists.postgresql.org; Fri, 03 May 2024 16:43:59 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s2w0o-001Gsk-Ri for pgsql-sql@lists.postgresql.org; Fri, 03 May 2024 16:43:56 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2b4952a1b51so44165a91.0 for ; Fri, 03 May 2024 09:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714754634; x=1715359434; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pbwP0auz6I1q6HXFusSGqwDTsum30/tptr4KhHVtljc=; b=jSCUd6bOOd/29H5nI+/yKPz9XAagxNTbCa3RnbFBQuerL3/oDURnqkwGei+kZZ2CjJ APR3qmJ5kya8CSCirsqYFIYi2zzOABmK5z6baQ8Tyxs0Hl22CFCn9PFGAx3MFZWUvuMb WJ0P/ZRoZJG/n1UEGj//eDa8A+j4787MlYEVAXn1Ono4horURmWxh7ntlLWeUD+wDcSe /BuPpXlDi3Um5BrLZ8rHuOqybmpL51Iw7JzT3ab8gZR5StDA+Qd9tXsD70LQsO3VK08R jgU/EtnsoaaD3TN6+JsEPQsb/48aGOsxe/m4mdHtqwX/a+kwvjR2RjtlxNcs1k5yn0GP o3kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714754634; x=1715359434; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pbwP0auz6I1q6HXFusSGqwDTsum30/tptr4KhHVtljc=; b=GhdxXvFynPISuGDgswbkIBvMdaKgrqUIBQslZnSr4sryiYKA5ctpaZDWacOWay8J9A ZQxqNX7uajZc360h8DfFvcUVlpZktbY/z49I2Q1nvQFt8Xd574mbJZO2Xe2ySocQQEzC IxgRTHV7NWOucBqucekqBX7R8Sumf5ZljxxD6XfujiAX+03ZtKbj+/KyeD3UObjLUaaV tUhwOtcX5hjtZ4YTdlb5JwVeo9xey2rffNtv5uHsUJAgfXnqDpO6R45uSLljI24m3ogL 5UsedNkUOi8WQI8Jba8sadEJnpMi2szGQqK5xD5QlJ95p+T/3QVMjlZNzPj06A/HiOl5 Hl4A== X-Gm-Message-State: AOJu0YzQ7vqdCCy+pu/3pCQcIqKuu2tG09ny3E6fH822af0BPE8vziNB SDr/JH7o8R3DENRRkMv0pXrEpNMJ6RQ8psr+299XhIwhZUs6vM10/RTKnlAu64U8o8dYgA0tye9 h20opfrfBE2nO+XSkBLKZl4Z9c3s= X-Google-Smtp-Source: AGHT+IG230yeVyq0nzwVdcosCoGhMFknQxzd5ERxRvM+63QkhmBmlULdwOffdQQIza0lp0YLu4WzxhUELloFq42z/5I= X-Received: by 2002:a17:90a:e397:b0:2ac:24ed:c930 with SMTP id b23-20020a17090ae39700b002ac24edc930mr3219637pjz.35.1714754633673; Fri, 03 May 2024 09:43:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Feike Steenbergen Date: Fri, 3 May 2024 18:43:42 +0200 Message-ID: Subject: Re: How to pass arguments in postgres to sql scripts. To: kunwar singh Cc: pgsql-sql@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 27 Apr 2024 at 15:03, kunwar singh wrote= : > > Hi friends, Question: How to pass arguments in postgres to sql scripts. = Context. When I am monitoring my production Oracle databases I have a lot o= f simple sql scripts (which require one or more arguments) which make my m= onitoring/troubleshooting life simpler. How can I achieve the same in postg= res? We are migrating our Oracle databases to Postgres and I am modifying = my scripts to do the same in Postgres. One way to do it is with --set $ psql --set var1=3Dpostgres -AtXq postgres=3D# select pid from pg_stat_activity where usename=3D:'var1'; 185 1939 Kind regards, Feike Steenbergen