1

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?

asked Mar 27, 2018 at 7:34

1 Answer 1

4

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

answered Mar 27, 2018 at 7:50
2
  • 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. Commented Mar 27, 2018 at 10:21
  • 2
    @Manngo: the common convention is to use a prefix like l_ for (local) variables and p_ for parameters passed to functions to distinguish them from column names. Commented Mar 27, 2018 at 12:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.