Passing and Parsing Arrays with PostgreSQL Functions

An interesting feature in PostgreSQL is the ability to easily pass arrays to functions.  In our example we're going to pass in an array to a PostgreSQL function, print out each of the array values and exit the function. We'll see how easy it is to pass and parse in PostgreSQL.

Here's our function. Notice the “_int4” input parameter to demonstrate an Integer Array.

Here's our select:

select count_by_two(ARRAY [4,7,15,18]);

And our output:

I told you it was easy…

More Like This Post