Chapter 45. PL/pgSQLSQL Procedural Language

Table of Contents

45.1. Overview
45.1.1. Advantages of Using PL/pgSQL
45.1.2. Supported Argument and Result Data Types
45.2. Structure of PL/pgSQL
45.3. Declarations
45.3.1. Declaring Function Parameters
45.3.2. ALIAS
45.3.3. Copying Types
45.3.4. Row Types
45.3.5. Record Types
45.3.6. Collation of PL/pgSQL Variables
45.4. Expressions
45.5. Basic Statements
45.5.1. Assignment
45.5.2. Executing SQL Commands
45.5.3. Executing a Command with a Single-Row Result
45.5.4. Executing Dynamic Commands
45.5.5. Obtaining the Result Status
45.5.6. Doing Nothing At All
45.6. Control Structures
45.6.1. Returning from a Function
45.6.2. Returning from a Procedure
45.6.3. Calling a Procedure
45.6.4. Conditionals
45.6.5. Simple Loops
45.6.6. Looping through Query Results
45.6.7. Looping through Arrays
45.6.8. Trapping Errors
45.6.9. Obtaining Execution Location Information
45.7. Cursors
45.7.1. Declaring Cursor Variables
45.7.2. Opening Cursors
45.7.3. Using Cursors
45.7.4. Looping through a Cursor's Result
45.8. Transaction Management
45.9. Errors and Messages
45.9.1. Reporting Errors and Messages
45.9.2. Checking Assertions
45.10. Trigger Functions
45.10.1. Triggers on Data Changes
45.10.2. Triggers on Events
45.11. PL/pgSQL under the Hood
45.11.1. Variable Substitution
45.11.2. Plan Caching
45.12. Tips for Developing in PL/pgSQL
45.12.1. Handling of Quotation Marks
45.12.2. Additional Compile-Time and Run-Time Checks
45.13. Porting from Oracle PL/SQL
45.13.1. Porting Examples
45.13.2. Other Things to Watch For
45.13.3. Appendix