Commit 769159fd authored by Tom Lane's avatar Tom Lane

Docs: minor improvements for documentation about plpgsql triggers.

Fabien Coelho, some further wordsmithing by me
parent 8ba4ccda
...@@ -3660,18 +3660,27 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl ...@@ -3660,18 +3660,27 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
<secondary>in PL/pgSQL</secondary> <secondary>in PL/pgSQL</secondary>
</indexterm> </indexterm>
<para>
<application>PL/pgSQL</application> can be used to define trigger
procedures on data changes or database events.
A trigger procedure is created with the <command>CREATE FUNCTION</>
command, declaring it as a function with no arguments and a return type of
<type>trigger</> (for data change triggers) or
<type>event_trigger</> (for database event triggers).
Special local variables named <varname>PG_<replaceable>something</></> are
automatically defined to describe the condition that triggered the call.
</para>
<sect2 id="plpgsql-dml-trigger"> <sect2 id="plpgsql-dml-trigger">
<title>Triggers on Data Changes</title> <title>Triggers on Data Changes</title>
<para> <para>
<application>PL/pgSQL</application> can be used to define trigger A <link linkend="triggers">data change trigger</> is declared as a
procedures. A trigger procedure is created with the function with no arguments and a return type of <type>trigger</>.
<command>CREATE FUNCTION</> command, declaring it as a function with Note that the function must be declared with no arguments even if it
no arguments and a return type of <type>trigger</type>. Note that expects to receive some arguments specified in <command>CREATE TRIGGER</>
the function must be declared with no arguments even if it expects &mdash; such arguments are passed via <varname>TG_ARGV</>, as described
to receive arguments specified in <command>CREATE TRIGGER</> &mdash; below.
trigger arguments are passed via <varname>TG_ARGV</>, as described
below.
</para> </para>
<para> <para>
...@@ -4218,8 +4227,9 @@ SELECT * FROM sales_summary_bytime; ...@@ -4218,8 +4227,9 @@ SELECT * FROM sales_summary_bytime;
<title>Triggers on Events</title> <title>Triggers on Events</title>
<para> <para>
<application>PL/pgSQL</application> can be used to define event <application>PL/pgSQL</application> can be used to define
triggers. <productname>PostgreSQL</> requires that a procedure that <link linkend="event-triggers">event triggers</>.
<productname>PostgreSQL</> requires that a procedure that
is to be called as an event trigger must be declared as a function with is to be called as an event trigger must be declared as a function with
no arguments and a return type of <literal>event_trigger</>. no arguments and a return type of <literal>event_trigger</>.
</para> </para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment