Planning and designing triggers
A trigger is a database object that can be used to perform some action in response to the INSERT, UPDATE
, or DELETE
operations. Triggers are very useful to enforce business rules. For example, if our business policy doesn't allow any employee's salary to be higher than his manager, then we can check the salaries before we actually make the change in the table and accept or reject the update. This also eases the application development, as we don't have to implement business policies in all applications and we can have them centralized in the database.
Multiple triggers can be specified for a combination of table, event (INSERT, UPDATE
, or DELETE)
, or activation time (BEFORE, AFTER
, or INSTEAD OF)
. When more than one trigger exists for a particular table, event, and activation time, the order in which the triggers are activated is the same as the order in which they were created. Thus, the most recently created trigger is the last trigger to be activated.
DB2...