What is the order of execution if there is a statement level and row level trigger on a same table?

Showing Answers 1 - 8 of 8 Answers

xxxx

  • Jan 31st, 2007
 

Always the statement level trigger executes first on a tablexxx

  Was this answer useful?  Yes

Faizal

  • Feb 26th, 2007
 

The Order will be:

Before Statement level
Before Row level
After Row level
After Statement level

Trigger firining sequence:
1) Before statement level triggers, if present

2) For each statement
    a) Before row level triggers, if present
    b)Statement itself
    c)After row level triggers, if present

3) After statement level triggers

  Was this answer useful?  Yes

binurajnair

  • Feb 28th, 2008
 

Just a small correction,

Trigger firining sequence:
1) Before statement level triggers, if present

2) For each row   

a) Before row level triggers, if present
    b)Statement itself
  c)After row level triggers, if present

3) After statement level triggers

  Was this answer useful?  Yes

The correct order is as below.


Trigger firing sequence:
1) Before statement level triggers, if present


2) For each row


a) Before row level triggers, if present
b) After row level triggers, if present


3) Actual Statement


4) After statement level triggers


create table d(col1 number primary key)
create table c(col1 number references d(col1))


create or replace trigger c_b4sttmnt
before insert on c
declare
vnum number;
begin
dbms_output.put_line('c_b4sttmnt');
end;


create or replace trigger c_aftrsttmnt
after insert on c
declare
vnum number;
begin
dbms_output.put_line('c_aftrsttmnt');
end;


create or replace trigger c_aftrrow
after insert on c
for each row
declare
vnum number;
begin
dbms_output.put_line('c_aftrrow');
end;


create or replace trigger c_b4row
before insert on c
for each row
declare
vnum number;
begin
dbms_output.put_line('c_b4row');
end;


Please execute the following command which will fail after first 3 triggers.
insert into c values(1);
c_b4sttmnt
c_b4row
c_aftrrow
ORA-02291: integrity constraint (STAGE.SYS_C0049041) violated - parent key not
found


Regards
- BHAILOGONLINE

  Was this answer useful?  Yes

Baji Shaik

  • Jun 5th, 2011
 

the orders of triggers execution is like this
    
  1.before statement level
   2.before row level
   3. after row level
   4 after statement level

  Was this answer useful?  Yes

Amol Bakane

  • Apr 2nd, 2018
 

The following hierarchy is followed when a trigger is fired.
1) BEFORE statement trigger fires first.
2) Next BEFORE row level trigger fires, once for each row affected.
3) Then AFTER row level trigger fires once for each affected row.
This events will alternates between BEFORE and AFTER row level triggers.
4) Finally the AFTER statement level trigger fires.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions