The TL;DR; Guide to PostgreSQL Functions

The Solarium

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.

  1. 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.
  2. Use the opening phrase “create or replace function …” so that you can quickly reload the code while debugging.
  3. 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.
  4. The argument is in parentheses and is a comma separated list of names and simple PostgreSQL types like int, text, or varchar.
  5. 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.
  6. PostgreSQL can overload functions by method signature…

View original post 396 more words

About isomorphismes

Argonaut: someone engaged in a dangerous but potentially rewarding adventure.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s