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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2004-10-31 15:41:06 Re: View's rule on delete problem
Previous Message Tom Lane 2004-10-31 15:29:15 Re: View's rule on delete problem