Re: How to pass arguments in postgres to sql scripts. - Mailing list pgsql-sql

From Feike Steenbergen
Subject Re: How to pass arguments in postgres to sql scripts.
Date
Msg-id CAK_s-G0DXgxRJHbhcaUFyBi5+CW-C9J2u-m8RXWsw9CB=q6YvA@mail.gmail.com
Whole thread Raw
In response to How to pass arguments in postgres to sql scripts.  (kunwar singh <krishsingh.111@gmail.com>)
List pgsql-sql
On Sat, 27 Apr 2024 at 15:03, kunwar singh <krishsingh.111@gmail.com> wrote:
>
> Hi friends,  Question: How to pass arguments in postgres to sql scripts. Context. When I am monitoring my production
Oracledatabases I have a lot of simple sql scripts (which require one or more arguments)  which make my
monitoring/troubleshootinglife simpler. How can I achieve the same in postgres? We are migrating our Oracle databases
toPostgres  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



pgsql-sql by date:

Previous
From: Nic Mitchell
Date:
Subject: Re: One parent record with 3 possible child records
Next
From: Bo Guo
Date:
Subject: Small table selection extremely slow!