Create Trigger, Delete Trigger
These two commands let you add and remove triggers for tables in a database.
Usage |
CREATE TRIGGER ON TableName FOR INSERT | UPDATE | DELETE AS lTrigger DELETE TRIGGER ON TableName FOR INSERT | UPDATE | DELETE |
When a trigger returns .F. in a Browse, it bypasses any custom error handler, and FoxPro's default "Trigger failed" message appears. This is generally a concern only in the development environment, however, since your error handler is correctly called when the trigger returns .F. in a grid. |
The Delete trigger doesn't fire when you ZAP a table. Although we think using ZAP on a table is a terrible mistake, except on your own test data, this is an absolute violation of the integrity of the database. It leaves a huge landmine in the path of any user who knows enough to be dangerous. |
Example |
CREATE TRIGGER ON MyTable FOR INSERT AS MyTrigger * And here's the trigger code PROCEDURE MyTrigger WAIT WINDOW "New record added. Total is now " + ; LTRIM(STR(RECCOUNT())) RETURN .T. |
See Also |
AfterModifyTable, BeforeModifyTable, Create Database, Create Table, Modify Database, _TriggerLevel, Zap |