Chapter 5. PL/PGSQL

PostgreSQL provides a special programming language for developing functions within SQL code. This programming language (that's the reason why it is called PL/pgSQL) offers the programmer far more execution potential than simple SELECT, INSERT, or UPDATE commands. The power of PL/pgSQL can be used to solve problems that cannot be solved with pure SQL statements. The package was initially written by Jan Wieck. Let's take a look at the main ideas and basic concepts of PL/pgSQL.

PL/pgSQL is a procedural language and is similar to Oracle's PL/SQL (see the section titled “Why Use PL/pgSQL,” later in this chapter). Like PL/SQL, PL/pgSQL is a block-oriented language that supports variable declaration, loops, logical constructs, and ...

Get PostgreSQL Developer's Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.