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 ...

Get IBM DB2 9.7 Advanced Application Developer Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.