Chapter 44. PL/pgSQLSQL Procedural Language

Table of Contents

44.1. Overview
44.1.1. Advantages of Using PL/pgSQL
44.1.2. Supported Argument and Result Data Types
44.2. Structure of PL/pgSQL
44.3. Declarations
44.3.1. Declaring Function Parameters
44.3.2. ALIAS
44.3.3. Copying Types
44.3.4. Row Types
44.3.5. Record Types
44.3.6. Collation of PL/pgSQL Variables
44.4. Expressions
44.5. Basic Statements
44.5.1. Assignment
44.5.2. Executing SQL Commands
44.5.3. Executing a Command with a Single-Row Result
44.5.4. Executing Dynamic Commands
44.5.5. Obtaining the Result Status
44.5.6. Doing Nothing At All
44.6. Control Structures
44.6.1. Returning from a Function
44.6.2. Returning from a Procedure
44.6.3. Calling a Procedure
44.6.4. Conditionals
44.6.5. Simple Loops
44.6.6. Looping through Query Results
44.6.7. Looping through Arrays
44.6.8. Trapping Errors
44.6.9. Obtaining Execution Location Information
44.7. Cursors
44.7.1. Declaring Cursor Variables
44.7.2. Opening Cursors
44.7.3. Using Cursors
44.7.4. Looping through a Cursor's Result
44.8. Transaction Management
44.9. Errors and Messages
44.9.1. Reporting Errors and Messages
44.9.2. Checking Assertions
44.10. Trigger Functions
44.10.1. Triggers on Data Changes
44.10.2. Triggers on Events
44.11. Packages
44.12. PL/pgSQL under the Hood
44.12.1. Variable Substitution
44.12.2. Plan Caching
44.13. Tips for Developing in PL/pgSQL
44.13.1. Handling of Quotation Marks
44.13.2. Additional Compile-Time and Run-Time Checks
44.14. Porting from Oracle PL/SQL
44.14.1. Porting Examples
44.14.2. Other Things to Watch For
44.14.3. Appendix