PL/pgSQL
PL/pgSQL (Procedural Language/PostgreSQL) is a procedural programming language supported by the PostgreSQL ORDBMS. It closely resembles Oracle's PL/SQL language. With PosgreSQL v9.X some ISO SQL/PSM features, like overloading of SQL-invoked functions and procedures,[1] supported.
PL/pgSQL, as a fully featured programming language, allows much more procedural control than SQL, including the ability to use loops and other control structures. Functions created in the PL/pgSQL language can be called from an SQL statement, or as the action that a trigger performs.
PL/pgSQL was created to be able to perform more complex operations and computations than SQL, while being easy to use, and is able to be defined as trusted by the server.[2]
PL/pgSQL is the only programming language installed by default for PostgreSQL, but many others are available, including PL/Java, PL/Perl, PL/php, PL/Python, PL/R, PL/Ruby, PL/sh, PL/Tcl, and PL/Lua. PostgreSQL use Bison in its parser-stage,[3] so it is easy to port many open source languages, as well as reuse code.
Comparing with PSM
The SQL/PSM language is specified by an ISO standard, but also inspired into Oracle's PL/SQL and pgPL/SQL, so there are only few differences. Main features of PSM that differ from PL/pgSQL:[4]
- Exception handlers are subroutines (continue handlers);
- Warnings can be handled like an exception;
- Declaration of variables should be based on SQL query result.
References
- ↑ feature T322
- ↑ "PL/pgSQL - SQL Procedural Language". Retrieved 2007-11-15.
- ↑ http://www.postgresql.org/docs/9.0/static/parser-stage.html
- ↑ Proposal: PL/pgPSM for pg9.3, by P. Stehule; and PosgreSQL-PSM-addon Manual
External links
- Official PL/pgSQL documentation
- PL/pgSQL (en), tutorial and examples