psql variables in the DO command

From: Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: psql variables in the DO command
Date: 2018-03-05 13:13:16
Message-ID: 5bae153c-ade4-ad24-bd46-857993240cfd@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

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

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James Keener 2018-03-05 13:33:18 Re: Requiring pass and database psql shell command
Previous Message Łukasz Jarych 2018-03-05 12:55:46 Requiring pass and database psql shell command