create_trigger man page on BSDi

Man page or keyword search:  
man Server   6284 pages
apropos Keyword Search (all sections)
Output format
BSDi logo
[printable version]

CREATE TRIGGER()		 SQL Commands		      CREATE TRIGGER()

NAME
       CREATE TRIGGER - Creates a new trigger

SYNOPSIS
       CREATE TRIGGER name { BEFORE | AFTER } { event [OR ...] }
	   ON table FOR EACH { ROW | STATEMENT }
	   EXECUTE PROCEDURE func ( arguments )

   INPUTS
       name   The name of an existing trigger.

       table  The name of a table.

       event  One of INSERT, DELETE or UPDATE.

       func   A user-supplied function.

   OUTPUTS
       CREATE This message is returned if the trigger is successfully created.

DESCRIPTION
       CREATE TRIGGER will enter a new trigger into the current data base. The
       trigger will be associated with the relation table and will execute the
       specified function func.

       The trigger can be specified to fire either before BEFORE the operation
       is attempted on a tuple (before constraints are checked and the INSERT,
       UPDATE  or  DELETE  is  attempted)  or  AFTER  the  operation  has been
       attempted (e.g., after constraints are checked and the  INSERT,	UPDATE
       or  DELETE  has	completed). If the trigger fires before the event, the
       trigger may 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	inser‐
       tion, update, or deletion, are "visible" to the trigger.

       Refer  to  the  chapters on SPI and Triggers in the PostgreSQL Program‐
       mer's Guide for more information.

   NOTES
       CREATE TRIGGER is a Postgres language extension.

       Only the relation owner may create a trigger on this relation.

       As of the current release (v7.0), STATEMENT  triggers  are  not	imple‐
       mented.

       Refer to DROP TRIGGER for information on how to remove triggers.

USAGE
       Check  if the specified distributor code exists in the distributors ta‐
       ble before appending or updating a row in the table films:

       CREATE TRIGGER if_dist_exists
	   BEFORE INSERT OR UPDATE ON films FOR EACH ROW
	   EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');

       Before cancelling a distributor or updating its code, remove every ref‐
       erence to the table films:

       CREATE TRIGGER if_film_exists
	   BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
	   EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');

COMPATIBILITY
   SQL92
       There is no CREATE TRIGGER in SQL92.

       The  second  example above may also be done by using a FOREIGN KEY con‐
       straint as in:

       CREATE TABLE distributors (
	   did	    DECIMAL(3),
	   name	    VARCHAR(40),
	   CONSTRAINT if_film_exists
	   FOREIGN KEY(did) REFERENCES films
	   ON UPDATE CASCADE ON DELETE CASCADE
       );

SQL - Language Statements	 29 March 2001		      CREATE TRIGGER()
[top]

List of man pages available for BSDi

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net