Re: psql variables in the DO command

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: psql variables in the DO command
Дата
Msg-id CAFj8pRCf0=rnpccADpt6tZepjxQneJ_Tz900Owjbd6jZAxChDQ@mail.gmail.com
обсуждение исходный текст
Ответ на psql variables in the DO command  (Pavel Luzanov <p.luzanov@postgrespro.ru>)
Ответы Re: psql variables in the DO command
Список pgsql-general
Hi

2018-03-05 14:13 GMT+01:00 Pavel Luzanov <p.luzanov@postgrespro.ru>:
Hello,

I can't use psql variable in the DO command. Is it intentional behavior?

yes. psql variables living on client side, and are not accessible from server side . DO command is executed on server side.

you can copy psql variables to GUC variables by set_config function, and then on server side use current_setting function for getting the content.

Regards

Pavel

 

postgres=# \set var 'Hello, World!'

postgres=# do $$begin raise notice '%', :'var'; end;$$;

ERROR:  syntax error at or near ":"

LINE 1: do $$begin raise notice '%', :'var'; end;$$;

                                     ^


--

-----
Pavel Luzanov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



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

Предыдущее
От: James Keener
Дата:
Сообщение: Re: Requiring pass and database psql shell command
Следующее
От: Pavel Luzanov
Дата:
Сообщение: Re: psql variables in the DO command