On Fri, Aug 12, 2016 at 11:34 PM, Xtra Coder <xtracoder@xxxxxxxxx> wrote: ... > In my particular case I'm more interested in an easy way to create complex > SELECTs that require usage of variables in the one-time through-away scripts > (some-time during experiments for implementation of functions, to see > immediate results of the intermediate code). The easiest way would be > MsSQL-like when declaring a variable outside of SP actually makes it visible > globally in current session. In such case I do not need 'DO' at all and this > is simple. Probably PostgreSQL has another way to make that thing simple. If you are just interested in avoiding some mistakes, and/or parametrizing some queries from the command line, psql ( the CLI program ) has macro expansion with some sql quoting capabilities, see https://www.postgresql.org/docs/9.5/static/app-psql.html#APP-PSQL-VARIABLES and be sure to scroll down to "SQL Interpolation" after the built in variables list and read that. I've used it several times, just remember it's a macro processor and it's done by psql, not by the server. Francisco Olarte. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general