Re: psql variables

Поиск
Список
Период
Сортировка
От Oleg Bartunov
Тема Re: psql variables
Дата
Msg-id Pine.GSO.4.62.0503271040090.17555@ra.sai.msu.su
обсуждение исходный текст
Ответ на Re: psql variables  (ptjm@interlog.com (Patrick TJ McPhee))
Список pgsql-general
On Fri, 25 Mar 2005, Patrick TJ McPhee wrote:

> In article <4235B688.8000407@blueseacommunications.com>,
> Paul Cunningham <paul@blueseacommunications.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@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

В списке pgsql-general по дате отправления:

Предыдущее
От: Madison Kelly
Дата:
Сообщение: Re: Perl and AutoCommit
Следующее
От: Tom Lane
Дата:
Сообщение: Re: create or replace trigger?