Home
About
Download
Documentation
Community
Developers
Support
Donate
Your account
November 14, 2024:
PostgreSQL 17.1, 16.5, 15.9, 14.14, 13.17, and 12.21 Released!
Documentation
→
PostgreSQL 12
Supported Versions:
Current
(
17
) /
16
/
15
/
14
/
13
Development Versions:
devel
Unsupported versions:
12
/
11
/
10
/
9.6
/
9.5
/
9.4
/
9.3
/
9.2
/
9.1
/
9.0
/
8.4
/
8.3
/
8.2
/
8.1
/
8.0
/
7.4
/
7.3
/
7.2
/
7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the
current
version, or one of the other supported versions listed above instead.
Chapter 42.
PL/pgSQL
-
SQL
Procedural Language
Prev
Up
Part V. Server Programming
Home
Next
Chapter 42.
PL/pgSQL
-
SQL
Procedural Language
Table of Contents
42.1. Overview
42.1.1. Advantages of Using
PL/pgSQL
42.1.2. Supported Argument and Result Data Types
42.2. Structure of
PL/pgSQL
42.3. Declarations
42.3.1. Declaring Function Parameters
42.3.2.
ALIAS
42.3.3. Copying Types
42.3.4. Row Types
42.3.5. Record Types
42.3.6. Collation of
PL/pgSQL
Variables
42.4. Expressions
42.5. Basic Statements
42.5.1. Assignment
42.5.2. Executing a Command with No Result
42.5.3. Executing a Query with a Single-Row Result
42.5.4. Executing Dynamic Commands
42.5.5. Obtaining the Result Status
42.5.6. Doing Nothing At All
42.6. Control Structures
42.6.1. Returning from a Function
42.6.2. Returning from a Procedure
42.6.3. Calling a Procedure
42.6.4. Conditionals
42.6.5. Simple Loops
42.6.6. Looping through Query Results
42.6.7. Looping through Arrays
42.6.8. Trapping Errors
42.6.9. Obtaining Execution Location Information
42.7. Cursors
42.7.1. Declaring Cursor Variables
42.7.2. Opening Cursors
42.7.3. Using Cursors
42.7.4. Looping through a Cursor's Result
42.8. Transaction Management
42.9. Errors and Messages
42.9.1. Reporting Errors and Messages
42.9.2. Checking Assertions
42.10. Trigger Functions
42.10.1. Triggers on Data Changes
42.10.2. Triggers on Events
42.11.
PL/pgSQL
under the Hood
42.11.1. Variable Substitution
42.11.2. Plan Caching
42.12. Tips for Developing in
PL/pgSQL
42.12.1. Handling of Quotation Marks
42.12.2. Additional Compile-Time and Run-Time Checks
42.13. Porting from
Oracle
PL/SQL
42.13.1. Porting Examples
42.13.2. Other Things to Watch For
42.13.3. Appendix