Chapter 36. PL/pgSQL - SQL Procedural Language

Table of Contents
36.1. Overview
36.1.1. Advantages of Using PL/pgSQL
36.1.2. Supported Argument and Result Data Types
36.2. Tips for Developing in PL/pgSQL
36.3. Structure of PL/pgSQL
36.4. Declarations
36.4.1. Aliases for Function Parameters
36.4.2. Copying Types
36.4.3. Row Types
36.4.4. Record Types
36.4.5. RENAME
36.5. Expressions
36.6. Basic Statements
36.6.1. Assignment
36.6.2. SELECT INTO
36.6.3. Executing an Expression or Query With No Result
36.6.4. Doing Nothing At All
36.6.5. Executing Dynamic Commands
36.6.6. Obtaining the Result Status
36.7. Control Structures
36.7.1. Returning From a Function
36.7.2. Conditionals
36.7.3. Simple Loops
36.7.4. Looping Through Query Results
36.7.5. Trapping Errors
36.8. Cursors
36.8.1. Declaring Cursor Variables
36.8.2. Opening Cursors
36.8.3. Using Cursors
36.9. Errors and Messages
36.10. Trigger Procedures
36.11. Porting from Oracle PL/SQL
36.11.1. Porting Examples
36.11.2. Other Things to Watch For
36.11.3. Appendix

PL/pgSQL is a loadable procedural language for the PostgreSQL database system. The design goals of PL/pgSQL were to create a loadable procedural language that

Except for input/output conversion and calculation functions for user-defined types, anything that can be defined in C language functions can also be done with PL/pgSQL. For example, it is possible to create complex conditional computation functions and later use them to define operators or use them in index expressions.