-Oracle trigger note-the execution sequence is: #1. Execute the before statement-Level Trigger. For each row affected by the statement: -- #2. Execute the Level Trigger and execute the DML statement-
-Oracle trigger note-the execution sequence is: #1. Execute the before statement-Level Trigger. For each row affected by the statement: -- #2. Execute the Level Trigger and execute the DML statement-
Create or replace trigger emp
-- Before indicates the trigger before the operation
-- After indicates the trigger after the operation
-- Up to 12 triggers can be created for each table
-- Before inset
-- Before insert for each row
-- After insert
-- After insert for each row
-- Before uPdate
-- Before uPdate for each row
-- After uPdate
-- After uPdate for each row
-- Before uPdate
-- Before uPdate for each row
-- After uPdate
-- After uPdate for each row
-- The execution order is: #1. Execute the before statement-Level Trigger, for each row affected by the statement:
-- #2. Execute the Level Trigger and execute the DML statement
-- Execute the after row-Level Trigger
-- #3. Execute an after statement-Level Trigger
Before delete on aaa -- trigger for the aaa table before the delete operation
For each row -- execute the trigger once for each row of the table. If this option is not available, the entire table is executed only once.
Declare
Begin
/* If you insert an aaa table, the following error occurs in row 1st:
ORA-04091: The Table QUERY. AAA has changed and the trigger/function cannot read it
ORA-06512: In "QUERY. EMP", line 4 (QUERY represents user, line represents number of rows, EMP represents trigger name)
ORA-04088: An error occurred while executing the trigger 'query. emp */
/* Insert the data before modification to the aaa_tmp log table for supervision */
Insert into aaa_tmp (AID, ANAME, PRICE)
Values (: old. AID,: old. ANAME,: old. PRICE); --: old indicates the original data,
--: New indicates the new data to be inserted.
End emp;