Introduction
PL/pgSQL has been influenced by the PL/SQL language, which is the Oracle stored procedural language. PL/pgSQL is a complete procedural language with rich control structures and full integration with the PostgreSQL trigger, index, rule, user defined data type, and operator objects.
There are several advantages of using PL/pgSQL; they are as follows:
It is easy to use and learn
It has very good support and documentation
It has very flexible result data types, and it supports polymorphism
It can return scalar values and sets using different return methods
SQL language and PL/pgSQL – a comparison
As shown in Chapter 4, PostgreSQL Advanced Building Blocks, one can write functions in C, SQL, and PL/pgSQL. There are some pros and cons of each approach. One can think of an SQL function as a wrapper around a parameterized SELECT
statement. SQL functions can be in-lined into the calling subquery leading to a better performance. Also, since the SQL function execution plan is not cashed as in...