Difference between revisions of "CREATE TRIGGER"
From Lianjapedia
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) (→Description) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 18: | Line 18: | ||
!width="50%"|Trigger||Operation | !width="50%"|Trigger||Operation | ||
|- | |- | ||
− | |DELETE||Attempt to delete an existing record. Corresponds to onbeforedelete trigger in listings. | + | |valign="top"|DELETE||Attempt to delete an existing record. Corresponds to onbeforedelete trigger in listings. |
|- | |- | ||
− | |ONAFTERDELETE||After deleting an existing record | + | |valign="top"|ONAFTERDELETE||After deleting an existing record |
|- | |- | ||
− | |INSERT||Attempt to add a new record. Corresponds to onbeforeinsert trigger in listings. | + | |valign="top"|INSERT||Attempt to add a new record. Corresponds to onbeforeinsert trigger in listings. |
|- | |- | ||
− | |ONAFTERINSERT||After adding a new record | + | |valign="top"|ONAFTERINSERT||After adding a new record |
|- | |- | ||
− | |UPDATE||Attempt to modify an existing record. Corresponds to onbeforeupdate trigger in listings. | + | |valign="top"|UPDATE||Attempt to modify an existing record. Corresponds to onbeforeupdate trigger in listings. |
|- | |- | ||
− | |ONAFTERUPDATE||After modifying an existing record | + | |valign="top"|ONAFTERUPDATE||After modifying an existing record |
|- | |- | ||
|} | |} | ||
Line 49: | Line 49: | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | CREATE TRIGGER ON customers FOR UPDATE AS not empty(custid) | |
− | CREATE TRIGGER ON | + | |
</code> | </code> | ||
Line 59: | Line 58: | ||
[[Category:Lianja VFP Extensions]] | [[Category:Lianja VFP Extensions]] | ||
[[Category:VFP Command Extensions]] | [[Category:VFP Command Extensions]] | ||
+ | [[Category:Database Triggers]] |
Latest revision as of 09:36, 22 December 2017
Contents
Purpose
Creates a trigger for a table
Syntax
CREATE TRIGGER ON [<database>!]<table>
FOR DELETE | ONAFTERDELETE | INSERT | ONAFTERINSERT | UPDATE | ONAFTERUPDATE
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 |
---|---|
DELETE | Attempt to delete an existing record. Corresponds to onbeforedelete trigger in listings. |
ONAFTERDELETE | After deleting an existing record |
INSERT | Attempt to add a new record. Corresponds to onbeforeinsert trigger in listings. |
ONAFTERINSERT | After adding a new record |
UPDATE | Attempt to modify an existing record. Corresponds to onbeforeupdate trigger in listings. |
ONAFTERUPDATE | After modifying 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 |
FOR DELETE | ONAFTERDELETE | INSERT | ONAFTERINSERT | UPDATE | ONAFTERUPDATE | Specifies the type of trigger to be created. |
expression | A logical expression to be evaluated |
Example
CREATE TRIGGER ON customers FOR UPDATE AS not empty(custid)