Difference between revisions of "CREATE TRIGGER"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision: SQL) |
Yvonne.milne (Talk | contribs) |
||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Creates a trigger for a table | Creates a trigger for a table | ||
− | |||
==Syntax== | ==Syntax== | ||
Line 9: | Line 8: | ||
AS <expression> | AS <expression> | ||
− | |||
==See Also== | ==See Also== | ||
− | [[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[SQL Data Types|DATA TYPES | + | [[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[SQL Data Types|DATA TYPES]], [[DELETE TRIGGER]], [[DROP TABLE]], [[GETENV()]], [[SQL INSERT|INSERT]], [[SQL SELECT|SELECT]], [[SET AUTOCATALOG]], [[SET XMLFORMAT]], |
− | + | ||
==Description== | ==Description== | ||
The CREATE TRIGGER command is used to create a trigger for the specified table. Triggers cause the logical <expression> to be evaluated when certain operations are attempted. | The CREATE TRIGGER command is used to create a trigger for the specified table. Triggers cause the logical <expression> to be evaluated when certain operations are attempted. | ||
− | |||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 30: | Line 25: | ||
|- | |- | ||
|} | |} | ||
− | |||
If the <expression> evaluates to False (.F.) the operation does not complete. If the <expression> evaluates to True (.T.) the operations does complete. | If the <expression> evaluates to False (.F.) the operation does not complete. If the <expression> evaluates to True (.T.) the operations does complete. | ||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
!Keywords||Description | !Keywords||Description | ||
|- | |- | ||
− | |database||The name of the database to which the table belongs | + | |database||The name of the database to which the table belongs. |
|- | |- | ||
|table||The name of the table | |table||The name of the table | ||
Line 47: | Line 40: | ||
|- | |- | ||
|} | |} | ||
− | |||
==Example== | ==Example== | ||
Line 54: | Line 46: | ||
CREATE TRIGGER ON customer FOR UPDATE AS not empty(CustName) | CREATE TRIGGER ON customer FOR UPDATE AS not empty(CustName) | ||
</code> | </code> | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
[[Category:Triggers]] | [[Category:Triggers]] |
Revision as of 11:09, 10 February 2012
Contents
Purpose
Creates a trigger for a table
Syntax
CREATE TRIGGER ON [<database>!]<table>
FOR UPDATE | INSERT | DELETE
AS <expression>
See Also
ADD TABLE, ALTER INDEX, ALTER TABLE, CONSTRAINTS, DATA TYPES, DELETE TRIGGER, DROP TABLE, GETENV(), INSERT, SELECT, SET AUTOCATALOG, SET XMLFORMAT,
Description
The CREATE TRIGGER command is used to create a trigger for the specified table. Triggers cause the logical <expression> to be evaluated when certain operations are attempted.
Trigger | Operation |
---|---|
UPDATE | Attempt to modify an existing record |
INSERT | Attempt to add a new record |
DELETE | Attempt to delete an existing record |
If the <expression> evaluates to False (.F.) the operation does not complete. If the <expression> evaluates to True (.T.) the operations does complete.
Keywords | Description |
---|---|
database | The name of the database to which the table belongs. |
table | The name of the table |
INSERT | DELETE | Specifies the type of trigger to be created. |
expression | A logical expression to be evaluated |
Example
USE accounts CREATE TRIGGER ON customer FOR UPDATE AS not empty(CustName)