<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.aletopedia.org/index.php?action=history&amp;feed=atom&amp;title=PL%2FpgSQL</id>
	<title>PL/pgSQL - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.aletopedia.org/index.php?action=history&amp;feed=atom&amp;title=PL%2FpgSQL"/>
	<link rel="alternate" type="text/html" href="https://www.aletopedia.org/index.php?title=PL/pgSQL&amp;action=history"/>
	<updated>2026-12-06T19:52:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://www.aletopedia.org/index.php?title=PL/pgSQL&amp;diff=853412&amp;oldid=prev</id>
		<title>imported&gt;Я сошла с ума: Adding local short description: &quot;Procedural programming language&quot;, overriding Wikidata description &quot;procedural programming language for PostgreSQL database systems&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.aletopedia.org/index.php?title=PL/pgSQL&amp;diff=853412&amp;oldid=prev"/>
		<updated>2025-11-11T09:05:16Z</updated>

		<summary type="html">&lt;p&gt;Adding local &lt;a href=&quot;https://en.wikipedia.org/wiki/Short_description&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Short description&quot;&gt;short description&lt;/a&gt;: &amp;quot;Procedural programming language&amp;quot;, overriding Wikidata description &amp;quot;procedural programming language for PostgreSQL database systems&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Procedural programming language}}&lt;br /&gt;
{{Infobox programming language&lt;br /&gt;
| name = PL/pgSQL&lt;br /&gt;
| title = &lt;br /&gt;
| logo = [[File:Postgresql elephant.svg|120px]]&lt;br /&gt;
| logo caption = &lt;br /&gt;
| screenshot =         &amp;lt;!-- (filename) --&amp;gt;&lt;br /&gt;
| screenshot caption = &lt;br /&gt;
| paradigm =           &amp;lt;!-- or: | paradigms = --&amp;gt;&lt;br /&gt;
| family =  &lt;br /&gt;
| designer = Jan Wieck&lt;br /&gt;
| developer = PostgreSQL Global Development Group&lt;br /&gt;
| released = {{start date and age|1998|10|30|df=no}}&lt;br /&gt;
| latest release version = &lt;br /&gt;
| latest release date =     &amp;lt;!-- {{start date and age|YYYY|MM|DD|df=yes/no}} --&amp;gt;&lt;br /&gt;
| latest preview version = &lt;br /&gt;
| latest preview date =     &amp;lt;!-- {{start date and age|YYYY|MM|DD|df=yes/no}} --&amp;gt;&lt;br /&gt;
| typing = &lt;br /&gt;
| scope = &lt;br /&gt;
| programming language = &lt;br /&gt;
| platform = &lt;br /&gt;
| operating system = &lt;br /&gt;
| license = &lt;br /&gt;
| file ext = &lt;br /&gt;
| file format =        &amp;lt;!-- or: | file formats = --&amp;gt;&lt;br /&gt;
| website = {{url|https://www.postgresql.org/docs/current/static/plpgsql.html}}&lt;br /&gt;
| implementations = &lt;br /&gt;
| dialects = &lt;br /&gt;
| influenced by = [[PL/SQL]], [[Ada (programming language)|Ada]]&lt;br /&gt;
| influenced = &lt;br /&gt;
}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;PL/pgSQL&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Procedural Language/PostgreSQL&amp;#039;&amp;#039;&amp;#039;) is a [[procedural programming|procedural]] [[programming language]] supported by the [[PostgreSQL]] [[ORDBMS]].  It closely resembles [[Oracle Database|Oracle]]&amp;#039;s [[PL/SQL]] language. Implemented by Jan Wieck, PL/pgSQL first appeared with PostgreSQL 6.4, released on October 30, 1998.&amp;lt;ref&amp;gt;{{cite web |url= https://www.postgresql.org/docs/current/static/release-6-4.html |title= PostgreSQL Documentation, Appendix E: Release Notes, Release 6.4 |date= January 2012 |publisher= PostgreSQL Global Development Group}}&amp;lt;/ref&amp;gt; Version 9 also implements some ISO [[SQL/PSM]] features, like overloading of SQL-invoked functions and procedures.&amp;lt;ref&amp;gt;{{Citation | publisher = PostgreSQL | title = SQL standard features | edition = 9 | contribution-url = https://www.postgresql.org/docs/9.0/static/features-sql-standard.html | contribution = feature T322}}.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[database trigger|trigger]]s can call functions created in the PL/pgSQL language.&lt;br /&gt;
&lt;br /&gt;
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.&amp;lt;ref&amp;gt;{{cite web | url = https://www.postgresql.org/docs/current/static/plpgsql.html | title = PL/pgSQL – SQL Procedural Language | publisher = PostgreSQL | accessdate = 2007-11-15}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PL/pgSQL is one of the programming languages included in the standard PostgreSQL distribution,&amp;lt;ref&amp;gt;{{cite web|title=Procedural Languages|date=9 May 2024 |url=https://www.postgresql.org/docs/current/static/xplang.html}}&amp;lt;/ref&amp;gt; the others being [https://www.postgresql.org/docs/current/static/pltcl.html PL/Tcl], PL/Perl&amp;lt;ref&amp;gt;{{Citation | title = Docs | contribution = PL/Perl | contribution-url = https://www.postgresql.org/docs/current/static/plperl.html | edition = current | publisher = PostgreSQL}}.&amp;lt;/ref&amp;gt; and PL/Python.&amp;lt;ref&amp;gt;{{Citation | title = Docs | contribution = PL/Python | contribution-url = https://www.postgresql.org/docs/current/static/plpython.html | edition = current | publisher = PostgreSQL}}.&amp;lt;/ref&amp;gt; In addition, many others are available from third parties, including PL/Java,&amp;lt;ref&amp;gt;{{Citation | contribution = PL/Java | title = Gborg | type = project | contribution-url = https://tada.github.io/pljava/ | publisher = PostgreSQL}}.&amp;lt;/ref&amp;gt; PL/pgPSM,&amp;lt;ref name = PSM&amp;gt;{{Citation | title = SQL/PSM | date = 20 May 2008 | url = https://postgres.cz/wiki/SQL/PSM_Manual | publisher = PostgreSQL | type = manual}}.&amp;lt;/ref&amp;gt; PL/php,&amp;lt;ref&amp;gt;{{Citation | contribution = PL/PHP | contribution-url = https://public.commandprompt.com/projects/plphp/ | publisher = Command prompt | title = Community}}.&amp;lt;/ref&amp;gt; PL/R,&amp;lt;ref&amp;gt;{{Citation | last = Conway | first = Joe | title = PL/R | url = http://www.joeconway.com/plr/ | access-date = 2005-02-25 | archive-url = https://web.archive.org/web/20140619175406/http://www.joeconway.com/plr/ | archive-date = 2014-06-19 | url-status = dead }}.&amp;lt;/ref&amp;gt;  PL/Ruby,&amp;lt;ref&amp;gt;{{Citation | title = PL/Ruby | url = https://github.com/knu/postgresql-plruby | type = project | publisher = Ruby lang| date = 2018-11-23 }}.&amp;lt;/ref&amp;gt; &lt;br /&gt;
[https://github.com/petere/plsh PL/sh], &lt;br /&gt;
[https://github.com/pllua/pllua  PL/Lua], Postmodern&amp;lt;ref&amp;gt;{{Citation |last=Haverbeke |first=Marijn |title=marijnh/Postmodern |date=2024-05-27 |url=https://github.com/marijnh/Postmodern |access-date=2024-06-01}}&amp;lt;/ref&amp;gt; (based on [[Common Lisp]]) and [https://pgxn.org/dist/plv8/doc/plv8.html PL/v8].  PostgreSQL uses [[GNU bison|Bison]] as its parser,&amp;lt;ref&amp;gt;&lt;br /&gt;
{{Citation | title = Docs | edition = 9 &lt;br /&gt;
| contribution = Parser stage &lt;br /&gt;
| publisher = PostgreSQL &lt;br /&gt;
| contribution-url = https://www.postgresql.org/docs/9.0/static/parser-stage.html&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
making it easy to port many [[open-source model|open-source]] languages, as well as to [[Code reuse|reuse code]].&lt;br /&gt;
&lt;br /&gt;
== Comparing with PSM ==&lt;br /&gt;
The [[SQL/PSM]] language is specified by an ISO standard, but is also inspired by Oracle&amp;#039;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:&amp;lt;ref name = PSM /&amp;gt;&amp;lt;ref name = proposal&amp;gt;{{Citation | title=Hackers | type = mailing list | publisher = PostgreSQL | contribution-url = https://www.postgresql.org/message-id/CAFj8pRDWFdcjNSnwQB_3j1-rMO6b8=TmLTNBvDCSpRrOW2Dfeg@mail.gmail.com | contribution = Proposal: PL/pgPSM for pg9.3 | first = P | last = Stehule}}.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Exception handlers are subroutines (continue handlers);&lt;br /&gt;
* Warnings can be handled as an exception;&lt;br /&gt;
* Declaration of variables should be based on SQL query results.&lt;br /&gt;
&lt;br /&gt;
All three languages (Oracle PL/SQL,&amp;lt;ref&amp;gt;{{Citation | series = Database Online Documentation | edition = 11g Release 1 (11.1) | title = PL/SQL Language Reference | page = 87 | chapter = C. PL/SQL Program Limits | publisher = Oracle | chapter-url = http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/limits.htm#LNPLS018 | quote = PL/SQL is based on the programming language Ada.}}&amp;lt;/ref&amp;gt; PostgreSQL PL/pgSQL and ISO SQL/PSM&amp;lt;ref&amp;gt;{{Citation | title = Stored procedures | chapter = 1 | publisher = O’Reilly | format = [[Open document presentation|ODP]] | url = http://cdn.oreillystatic.com/en/assets/1/event/36/Stored%2520Procedures%2520-%2520Part%25201%2520Presentation.odp}}.&amp;lt;/ref&amp;gt;) were heavily influenced by the [[Ada (programming language)|Ada programming language]].&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
The following example is a function that computes the sales tax of a given subtotal:&amp;lt;syntaxhighlight lang=&amp;quot;plpgsql&amp;quot;&amp;gt;&lt;br /&gt;
CREATE FUNCTION sales_tax(subtotal real) RETURNS real AS $$&lt;br /&gt;
BEGIN&lt;br /&gt;
    RETURN subtotal * 0.06;&lt;br /&gt;
END;&lt;br /&gt;
$$ LANGUAGE plpgsql;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[https://www.postgresql.org/docs/current/static/plpgsql.html Official PL/pgSQL documentation]&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:PL pgSQL}}&lt;br /&gt;
[[Category:SQL]]&lt;br /&gt;
[[Category:PostgreSQL]]&lt;br /&gt;
[[Category:Data-centric programming languages]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{compu-lang-stub}}&lt;/div&gt;</summary>
		<author><name>imported&gt;Я сошла с ума</name></author>
	</entry>
</feed>