User defined variables in PostgreSQL
Postgres does not normally use variables in plain SQL. But you can do that, too: SET foo.test=”SELECT bar FROM baz”; SELECT current_setting(‘foo.test’); Read about Customized Options in the manual. In PostgreSQL 9.1 or earlier you needed to declare custom_variable_classes before you could use that. However, You cannot EXECUTE dynamic SQL without a PL (procedural language). … Read more