4D v14.3Trigger event |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
Trigger event
Trigger event
Called from within a trigger, the Trigger event command returns a numeric value that denotes the type of the database event, in other words, the reason why the trigger has been invoked. The following predefined constants are provided in the Trigger Events theme:
Within a trigger, if you perform database operations on multiple records, you may encounter conditions (usually locked records) that will make the trigger unable to perform correctly. An example of this situation is updating multiple records in a [Products] table when a record is being added to an [Invoices] table. At this point, you must stop attempting database operations, and return a database error so the invoking process will know that its database request cannot be performed. Then the invoking process must be able to cancel, during the transaction, the incomplete database operations performed by the trigger. When this type of situation occurs, you need to know from within the trigger if you are in transaction even before attempting anything. To do so, use the command In transaction. When cascading trigger calls, 4D has no limit other than the available memory. To optimize trigger execution, you may want to write the code of your triggers depending not only on the database event, but also on the level of the call when triggers are cascaded. For example, during a deletion database event for the [Invoices] table, you may want to skip the update of the [Customers] Gross Sales field if the deletion of the [Invoices] record is part of the deletion of all the invoices related to a [Customers] record being deleted. To do so, use the commands Trigger level and TRIGGER PROPERTIES. You use the Trigger event command to structure your triggers as follows: // Trigger for [anyTable] |
PROPERTIES
Product: 4D
HISTORY
Modified: 4D v11 SQL Release 2 SEE ALSO
In transaction ARTICLE USAGE
4D Language Reference ( 4D v14 R3) Inherited from : Database event ( 4D v11 SQL Release 6) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||