public inbox for [email protected]  
help / color / mirror / Atom feed
From: Feike Steenbergen <[email protected]>
To: kunwar singh <[email protected]>
Cc: [email protected]
Subject: Re: How to pass arguments in postgres to sql scripts.
Date: Fri, 3 May 2024 18:43:42 +0200
Message-ID: <CAK_s-G0DXgxRJHbhcaUFyBi5+CW-C9J2u-m8RXWsw9CB=q6YvA@mail.gmail.com> (raw)
In-Reply-To: <CAJSrDUqgMx2+bhX0f9MWDT9LyC4E44wFbTiqC+wboHc__QyV_g@mail.gmail.com>
References: <CAJSrDUqgMx2+bhX0f9MWDT9LyC4E44wFbTiqC+wboHc__QyV_g@mail.gmail.com>

On Sat, 27 Apr 2024 at 15:03, kunwar singh <[email protected]> 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 of simple sql scripts (which require one or more arguments)  which make my monitoring/troubleshooting life simpler. How can I achieve the same in postgres? 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=postgres -AtXq
postgres=# select pid from pg_stat_activity where usename=:'var1';
185
1939

Kind regards,

Feike Steenbergen






view thread (3+ messages)

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: How to pass arguments in postgres to sql scripts.
  In-Reply-To: <CAK_s-G0DXgxRJHbhcaUFyBi5+CW-C9J2u-m8RXWsw9CB=q6YvA@mail.gmail.com>

* 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