Skip site navigation (1) Skip section navigation (2)

Re: Interpolation of environment variables in SQL at runtime?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andy Gimblett <A(dot)M(dot)Gimblett(at)swansea(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Interpolation of environment variables in SQL at runtime?
Date: 2004-10-31 15:31:06
Message-ID: 27811.1099236666@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Andy Gimblett <A(dot)M(dot)Gimblett(at)swansea(dot)ac(dot)uk> writes:
> Question: is there any way to use environment variables (or something
> similar) in my saved SQL code, and have them expanded at runtime?

Only by preprocessing the script.  Have you considered something like

cat <<EOF
... WHERE $foo = ...
EOF | psql ...

			regards, tom lane

In response to

pgsql-general by date

Next:From: Michael FuhrDate: 2004-10-31 15:41:06
Subject: Re: View's rule on delete problem
Previous:From: Tom LaneDate: 2004-10-31 15:29:15
Subject: Re: View's rule on delete problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group