I try to declare a variable in a code like this, but it\'s doesn\'t work. Can you tell me what\'s the problem?
ERROR: syntax error at or near \"VARCHAR\"
LI
Create a new setting in postgresql.conf for custom_variable_classes:
custom_variable_classes = 'var'
Reload the config, you now have the variable "var" available in all your databases.
To create the variable p_country, just use SET:
SET var.p_country = 'US';
SELECT current_setting('var.p_country') AS p_country;
It's not a beauty, but it works.