From: | Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> |
---|---|
To: | Patrick TJ McPhee <ptjm(at)interlog(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: psql variables |
Date: | 2005-03-27 06:43:15 |
Message-ID: | Pine.GSO.4.62.0503271040090.17555@ra.sai.msu.su |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 25 Mar 2005, Patrick TJ McPhee wrote:
> In article <4235B688(dot)8000407(at)blueseacommunications(dot)com>,
> Paul Cunningham <paul(at)blueseacommunications(dot)com> wrote:
> % I use a bash script (similar to following example) to update tables.
> %
> % psql -v passed_in_var=\'some_value\' -f script_name ....
> %
> % Is it possible to pass a value back from psql to the bash script?
>
> If you run it like this
>
> $(psql -v passed_in_var=\'some_value\' -f script_name)
>
> and arrange for all the script output to be in the form
>
> var1="value 1" var2="value 2"
> var3="value 3" ...
>
> then var1, var2, etc will be set in bash (or ksh, or the posix shell).
> Note that there are no spaces around the equals signs.
btw, how to expand psql variable in -c "" ?
For example, this works as expected
psql discovery-test -v a1=\'message_parts\' -f tt.sql
but not
psql discovery-test -v a1=\'message_parts\' -c "select * from iostat where relname=:a1;"
ERROR: parse error at or near ":" at character 36
LINE 1: select * from iostat where relname=:a1;
>
Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-03-27 06:49:31 | Re: create or replace trigger? |
Previous Message | Madison Kelly | 2005-03-27 06:34:23 | Re: Perl and AutoCommit |