I’ve spent many hours becoming (more or less) proficient in the ceremony around PostgreSQL functions; hours that hopefully you won’t have to spend after reading this! Here is a one minute list.
- Functions and Stored Procedures are all “Functions” in PostgreSQL, so don’t waste time searching for syntax related to “stored procedures” in the PostgreSQL manual.
- Use the opening phrase “create or replace function …” so that you can quickly reload the code while debugging.
- A function name may be schema qualified (eg- “my_schema.my_function”). If it is not schema qualified, it will go into the public schema.
- The argument is in parentheses and is a comma separated list of names and simple PostgreSQL types like int, text, or varchar.
- I usually prefix a “p_” to all my parameter names to make the following code more readable. You should too; you’ll thank me later.
- PostgreSQL can overload functions by method signature…
View original post 396 more words