Member-only story

Function parameters in a PLpgSQL function — How they are accessed…

Josh Otwell
2 min readJul 3, 2019

--

Having recently published this blog post about PLpgSQL dollar quoting, I thought it appropriate to follow-up with a post on function parameters. In this post, I will demonstrate 2 variations of a simple function, both of which accept a parameter. Yet, how the parameter is accessed and specified is different.

Photo by Lewis Ngugi on Unsplash

Note: All data, names or naming found within the database presented in this post, are strictly used for practice, learning, instruction, and testing purposes. It by no means depicts actual data belonging to or being used by any party or organization.

OS and DB used:

  • Xubuntu Linux 18.04.2 LTS (Bionic Beaver)
  • PostgreSQL 11.4

Self-Promotion:

If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!

I’ll use a couple of tables from the PostgreSQL practice DVD Rental database for the example queries below.

I have an arbitrary query that returns the ‘country_id’ for a city that we filter for with the LIKE predicate. I realize that without supplying a capital letter, an empty result set will likely be returned.

However, this functions primary purpose is for an example demonstration of how function parameters can be passed in and accessed in PLpgSQL.

Continue reading the full post here…

Originally published at https://joshuaotwell.com on July 3, 2019.

--

--

Josh Otwell
Josh Otwell

Written by Josh Otwell

SQL/PHP | Photography | Technical Consultant. Sign-up for my free developer newsletter, OpenLampTech, here: openlamptech.substack.com

No responses yet