5-12. Creating a Trigger That Fires on Multiple Events

Problem

You have logic that is very similar for two different events. Thus, you want to combine that logic into a single trigger that fires for both. For example, let's assume that we want to create a single trigger on the EMPLOYEES table with code to fire after each row that is inserted or modified and also with code to fire at the end of each of those statements' executions.xs

Solution

Use a compound trigger to combine all the triggers into a single body of code. The trigger in this solution will execute based upon various timing points. It will execute AFTER EACH ROW in the EMPLOYEES table has been updated, as well as AFTER the entire update statement has been executed. The AFTER EACH ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.