Chapter 46. PL/pgSQLSQL Procedural Language

Table of Contents

46.1. Overview
46.1.1. Advantages of Using PL/pgSQL
46.1.2. Supported Argument and Result Data Types
46.2. Structure of PL/pgSQL
46.3. Declarations
46.3.1. Declaring Function Parameters
46.3.2. ALIAS
46.3.3. Copying Types
46.3.4. Row Types
46.3.5. Record Types
46.3.6. Collation of PL/pgSQL Variables
46.4. Expressions
46.5. Basic Statements
46.5.1. Assignment
46.5.2. Executing SQL Commands
46.5.3. Executing a Command with a Single-Row Result
46.5.4. Executing Dynamic Commands
46.5.5. Obtaining the Result Status
46.5.6. Doing Nothing At All
46.6. Control Structures
46.6.1. Returning from a Function
46.6.2. Returning from a Procedure
46.6.3. Calling a Procedure
46.6.4. Conditionals
46.6.5. Simple Loops
46.6.6. Looping through Query Results
46.6.7. Looping through Arrays
46.6.8. Trapping Errors
46.6.9. Obtaining Execution Location Information
46.7. Cursors
46.7.1. Declaring Cursor Variables
46.7.2. Opening Cursors
46.7.3. Using Cursors
46.7.4. Looping through a Cursor's Result
46.8. Transaction Management
46.9. Errors and Messages
46.9.1. Reporting Errors and Messages
46.9.2. Checking Assertions
46.10. Trigger Functions
46.10.1. Triggers on Data Changes
46.10.2. Triggers on Events
46.11. Packages
46.12. PL/pgSQL under the Hood
46.12.1. Variable Substitution
46.12.2. Plan Caching
46.13. Tips for Developing in PL/pgSQL
46.13.1. Handling of Quotation Marks
46.13.2. Additional Compile-Time and Run-Time Checks
46.14. Porting from Oracle PL/SQL
46.14.1. Porting Examples
46.14.2. Other Things to Watch For
46.14.3. Appendix