I cannot find any definitive information on what constitutes a valid variable name in a PostgreSQL function.
I am assuming the function is written using plpgsql
. I know I can use letters, numerals (apart from the first character) and underscores. Is there anything else?
Where is this documented?
1 Answer 1
This is implicitly stated in the introduction to PL/pgSQL.
Identifiers are implicitly converted to lower case unless double-quoted, just as they are in ordinary SQL commands.
So a PL/pgSQL variable has to comply with the rules for SQL identifiers
-
Thanks for the references. I have found that I can use the
$
character. I am exploring whether to affix the$
to my variables to more reliably distinguish them from column names.Manngo– Manngo2018年03月27日 10:21:58 +00:00Commented Mar 27, 2018 at 10:21 -
2@Manngo: the common convention is to use a prefix like
l_
for (local) variables andp_
for parameters passed to functions to distinguish them from column names.user1822– user18222018年03月27日 12:14:23 +00:00Commented Mar 27, 2018 at 12:14