PL/pgSQL (Procedural Language/PostgreSQL) is a procedural programming language supported by the PostgreSQL ORDBMS. It closely resembles Oracle's PL/SQL language. Implemented by Jan Wieck, PL/pgSQL first appeared with PostgreSQL 6.4, released on October 30, 1998. Version 9 also implements some ISO SQL/PSM features, like overloading of SQL-invoked functions and procedures.
|Designed by||Jan Wieck|
|Developer||PostgreSQL Global Development Group|
|First appeared||October 30, 1998|
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. SQL statements and triggers can call functions created in the PL/pgSQL language.
The design of PL/pgSQL aimed to allow PostgreSQL users to perform more complex operations and computations than SQL, while providing ease of use. The language is able to be defined as trusted by the server.
PL/pgSQL is one of the programming languages included in the standard PostgreSQL distribution, the others being PL/Tcl, PL/Perl and PL/Python. In addition many others are available from third parties, including PL/Java, PL/pgPSM, PL/php, PL/R, PL/Ruby,PL/sh, PL/Lua and PL/v8. PostgreSQL uses Bison as its parser, making it easy to port many open-source languages, as well as to reuse code.
Comparing with PSMEdit
The SQL/PSM language is specified by an ISO standard, but is also inspired by Oracle's PL/SQL and PL/pgPL/SQL, so there are few differences. The PL/pgPSM contributed module implements the standard. The main features of PSM that differ from PL/pgSQL:
- Exception handlers are subroutines (continue handlers);
- Warnings can be handled like an exception;
- Declaration of variables should be based on SQL query result.
Inline documentation external supportEdit
This section does not cite any sources. (March 2016) (Learn how and when to remove this template message)
Formal pseudo-language for documentation, can be embedded into SQL and PL/pgSQL scripts, and will be processed (documentation data-extraction and documentation hypertext generation) by an external tool, the documentation generator. Some of these tools have support to PL/SQL, so, it is expected to support also PL/pgSQL, in full or partial support.
|Tool||Full PL/pgSQL||Javadoc style||Other style||PL/pgSQL projects using it|
Other documentation tools: Doxygen, DBScribe, HyperSQL, Universal Report.
- "PostgreSQL Documentation, Appendix E: Release Notes, Release 6.4". PostgreSQL Global Development Group.
- "feature T322", SQL standard features (9 ed.), PostgreSQL.
- "PL/pgSQL – SQL Procedural Language". PostgreSQL. Retrieved 2007-11-15.
- "Procedural Languages".
- "PL/Perl", Docs (current ed.), PostgreSQL.
- "PL/Python", Docs (current ed.), PostgreSQL.
- "PL/Java", Gborg (project), PostgreSQL.
- SQL/PSM (manual), PostgreSQL.
- "PL/PHP", Community, Command prompt.
- Conway, Joe, PL/R.
- PL/Ruby (project), Ruby lang, 2018-11-23.
- "Parser stage", Docs (9 ed.), PostgreSQL
- Stehule, P, "Proposal: PL/pgPSM for pg9.3", Hackers (mailing list), PostgreSQL.
- "C. PL/SQL Program Limits", PL/SQL Language Reference, Database Online Documentation (11g Release 1 (11.1) ed.), Oracle, p. 87,
PL/SQL is based on the programming language Ada.
- "1", Stored procedures (ODP)