For example, you can set the custom options my.num
and my.first.name
as variables as shown below. *My answer explains how to declare user-defined variables in detail:
SET my.num = 2;
SET my.first.name = 'John';
Or, you can set the custom options with set_config() as shown below:
SELECT set_config('my.num', '2', false);
SELECT set_config('my.first.name', 'John', false);
Then, you must use current_setting() to get the values of the custom options my.num
and my.first.name
as shown below:
postgres=# SELECT current_setting('my.num');
current_setting
-----------------
2
(1 row)
postgres=# SELECT current_setting('my.first.name');
current_setting
-----------------
John
(1 row)
Next for example, you can use \set to set the number 2
to num
as shown below:
postgres=# \set num 2
postgres=# SELECT :num;
?column?
----------
2
(1 row)
And, you can use \set
to set the text John Smith
with ''
to name
as shown below:
postgres=# \set name 'John Smith'
postgres=# SELECT :'name';
?column?
------------
John Smith
(1 row)
EXECUTE search_address_query;
? – Chessa