summaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/create_trigger.sgml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/sgml/ref/create_trigger.sgml')
-rw-r--r--doc/src/sgml/ref/create_trigger.sgml85
1 files changed, 40 insertions, 45 deletions
diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml
index b98c90aa21e..891cf209fd8 100644
--- a/doc/src/sgml/ref/create_trigger.sgml
+++ b/doc/src/sgml/ref/create_trigger.sgml
@@ -14,30 +14,24 @@
</REFPURPOSE>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
- <DATE>1998-04-15</DATE>
+ <DATE>1998-09-21</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
- CREATE TRIGGER <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> { BEFORE | AFTER }
- { <REPLACEABLE CLASS="PARAMETER">event</REPLACEABLE> [OR ...] }
- ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> FOR EACH { ROW | STATEMENT }
- EXECUTE PROCEDURE <REPLACEABLE CLASS="PARAMETER">funcname</REPLACEABLE> ( <REPLACEABLE CLASS="PARAMETER">arguments</REPLACEABLE> )
+CREATE TRIGGER <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> { BEFORE | AFTER }
+ { <REPLACEABLE CLASS="PARAMETER">event</REPLACEABLE> [OR ...] }
+ ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> FOR EACH { ROW | STATEMENT }
+ EXECUTE PROCEDURE <REPLACEABLE CLASS="PARAMETER">funcname</REPLACEABLE> ( <REPLACEABLE CLASS="PARAMETER">arguments</REPLACEABLE> )
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-CREATETRIGGER-1">
<REFSECT2INFO>
- <DATE>1998-04-15</DATE>
+ <DATE>1998-09-21</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- </TERM>
- <LISTITEM>
- <PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
@@ -80,14 +74,11 @@
</LISTITEM>
</VARLISTENTRY>
</variablelist>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATETRIGGER-2">
<REFSECT2INFO>
- <DATE>1998-04-15</DATE>
+ <DATE>1998-09-21</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
@@ -97,6 +88,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
+<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
@@ -120,24 +112,18 @@
<REFSECT1 ID="R1-SQL-CREATETRIGGER-1">
<REFSECT1INFO>
- <DATE>1998-04-15</DATE>
+ <DATE>1998-09-21</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
- CREATE TRIGGER will enter a new trigger into the current
+ <command>CREATE TRIGGER</command> will enter a new trigger into the current
data base. The trigger will be associated with the relation
<replaceable class="parameter">relname</replaceable> and will execute
the specified function <replaceable class="parameter">funcname</replaceable>.
</PARA>
<PARA>
- Only the relation owner may create a trigger on this relation.
- </PARA>
- <PARA>
- At release 6.3.2, STATEMENT triggers are not implemented.
- </PARA>
- <PARA>
The trigger can be specified to fire either before the
operation is attempted on a tuple (before constraints
are checked and the INSERT, UPDATE or DELETE is attempted) or
@@ -147,24 +133,32 @@
skip the operation for the current tuple, or change the tuple
being inserted (for INSERT and UPDATE operations only). If
the trigger fires after the event, all changes, including the
- last INSERTion, UPDATE or DELETion, are "visible" to the trigger.
+ last insertion, update, or deletion, are "visible" to the trigger.
</PARA>
<PARA>
- Refer to the SPI and trigger programming guides for more
+ Refer to the chapters on SPI and Triggers in the
+<citetitle>PostgreSQL Programmer's Guide</citetitle> for more
information.
</PARA>
<REFSECT2 ID="R2-SQL-CREATETRIGGER-3">
<REFSECT2INFO>
- <DATE>1998-04-15</DATE>
+ <DATE>1998-09-21</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
- CREATE TRIGGER statement is a PostgreSQL language extension.
+ <command>CREATE TRIGGER</command> is a <productname>Postgres</productname>
+ language extension.
</PARA>
+ <PARA>
+ Only the relation owner may create a trigger on this relation.
+ </PARA>
+ <PARA>
+ As of the current release (v6.4), STATEMENT triggers are not implemented.
+ </PARA>
<PARA>
- Refer to the DROP TRIGGER statement for information on how to
+ Refer to <command>DROP TRIGGER</command> for information on how to
remove triggers.
</PARA>
@@ -179,18 +173,18 @@
table before appending or updating a row in the table films:
</PARA>
<ProgramListing>
- CREATE TRIGGER if_dist_exists
- BEFORE INSERT OR UPDATE ON films FOR EACH ROW
- EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
+CREATE TRIGGER if_dist_exists
+ BEFORE INSERT OR UPDATE ON films FOR EACH ROW
+ EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
</ProgramListing>
<PARA>
Before cancelling a distributor or updating its code, remove every
reference to the table films:
</PARA>
<ProgramListing>
- CREATE TRIGGER if_film_exists
- BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
- EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
+CREATE TRIGGER if_film_exists
+ BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
+ EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
</ProgramListing>
</REFSECT1>
@@ -203,29 +197,30 @@
<REFSECT2 ID="R2-SQL-CREATETRIGGER-4">
<REFSECT2INFO>
- <DATE>1998-04-15</DATE>
+ <DATE>1998-09-21</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
- There is no CREATE TRIGGER statement in SQL92.
+ There is no <command>CREATE TRIGGER</command> in <acronym>SQL92</acronym>.
</PARA>
<PARA>
The second example above may also be done by using a FOREIGN KEY
constraint as in:
</PARA>
<ProgramListing>
- CREATE TABLE distributors (
- did DECIMAL(3),
- name VARCHAR(40),
- CONSTRAINT if_film_exists FOREIGN KEY(did) REFERENCES films
- ON UPDATE CASCADE ON DELETE CASCADE
- );
+CREATE TABLE distributors (
+ did DECIMAL(3),
+ name VARCHAR(40),
+ CONSTRAINT if_film_exists
+ FOREIGN KEY(did) REFERENCES films
+ ON UPDATE CASCADE ON DELETE CASCADE
+);
</ProgramListing>
<PARA>
- However, foreign keys are not yet implemented at version 6.3.2 of
- PostgreSQL.
+ However, foreign keys are not yet implemented (as of version 6.4) in
+ <productname>Postgres</productname>.
</PARA>
</REFENTRY>