The following example of a compound trigger records a change to the employee salary by defining a compound trigger (named hr_trigger) on the emp table.
First, create a table named emp.
Then, create a compound trigger named hr_trigger. The trigger is created for each of the four timing-points to INSERT, UPDATE, or DELETE salary in the emp table. In the global declaration section, the salary is declared as 10,000.
INSERT the record into table emp.
The INSERT statement produces the following output:
The UPDATE statement will update the employee salary record, setting the salary to 15000 for a specific employee number.
The UPDATE statement produces the following output:
The DELETE statement deletes the employee salary record.
The DELETE statement produces the following output:
The TRUNCATE statement removes all the records from the emp table.
The TRUNCATE statement produces the following output:
Note
The TRUNCATE statement may be used only at a BEFORE STATEMENT or AFTER STATEMENT timing-point.