@@ -3660,18 +3660,27 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
36603660 <secondary>in PL/pgSQL</secondary>
36613661 </indexterm>
36623662
3663+ <para>
3664+ <application>PL/pgSQL</application> can be used to define trigger
3665+ procedures on data changes or database events.
3666+ A trigger procedure is created with the <command>CREATE FUNCTION</>
3667+ command, declaring it as a function with no arguments and a return type of
3668+ <type>trigger</> (for data change triggers) or
3669+ <type>event_trigger</> (for database event triggers).
3670+ Special local variables named <varname>PG_<replaceable>something</></> are
3671+ automatically defined to describe the condition that triggered the call.
3672+ </para>
3673+
36633674 <sect2 id="plpgsql-dml-trigger">
36643675 <title>Triggers on Data Changes</title>
36653676
3666- <para>
3667- <application>PL/pgSQL</application> can be used to define trigger
3668- procedures. A trigger procedure is created with the
3669- <command>CREATE FUNCTION</> command, declaring it as a function with
3670- no arguments and a return type of <type>trigger</type>. Note that
3671- the function must be declared with no arguments even if it expects
3672- to receive arguments specified in <command>CREATE TRIGGER</> —
3673- trigger arguments are passed via <varname>TG_ARGV</>, as described
3674- below.
3677+ <para>
3678+ A <link linkend="triggers">data change trigger</> is declared as a
3679+ function with no arguments and a return type of <type>trigger</>.
3680+ Note that the function must be declared with no arguments even if it
3681+ expects to receive some arguments specified in <command>CREATE TRIGGER</>
3682+ — such arguments are passed via <varname>TG_ARGV</>, as described
3683+ below.
36753684 </para>
36763685
36773686 <para>
@@ -4218,8 +4227,9 @@ SELECT * FROM sales_summary_bytime;
42184227 <title>Triggers on Events</title>
42194228
42204229 <para>
4221- <application>PL/pgSQL</application> can be used to define event
4222- triggers. <productname>PostgreSQL</> requires that a procedure that
4230+ <application>PL/pgSQL</application> can be used to define
4231+ <link linkend="event-triggers">event triggers</>.
4232+ <productname>PostgreSQL</> requires that a procedure that
42234233 is to be called as an event trigger must be declared as a function with
42244234 no arguments and a return type of <literal>event_trigger</>.
42254235 </para>
0 commit comments