Re: How to pass arguments in postgres to sql scripts.
Feike Steenbergen <feikesteenbergen@gmail.com>
From: Feike Steenbergen <feikesteenbergen@gmail.com>
To: kunwar singh <krishsingh.111@gmail.com>
Cc: pgsql-sql@lists.postgresql.org
Date: 2024-05-03T16:43:42Z
Lists: 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 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