This discussion is archived
4 Replies Latest reply: Feb 12, 2013 7:49 AM by RajeshKanna RSS

Triggers

RajeshKanna Newbie
Currently Being Moderated
Hi,

I have Created two triggers on a table firstone is before insert and secondone is also before insert..
when i insert a new record into the table which Trigger will fire first..

Cheers,
Rajesh
  • 1. Re: Triggers
    sb92075 Guru
    Currently Being Moderated
    RajeshKanna wrote:
    Hi,

    I have Created two triggers on a table firstone is before insert and secondone is also before insert..
    when i insert a new record into the table which Trigger will fire first..

    Cheers,
    Rajesh
    INDETERMINATE

    if the order matters to you, then combine them into single trigger that executes code in desired order.
  • 2. Re: Triggers
    990622 Newbie
    Currently Being Moderated
    Or the other way can be that first you create trigger 1 and while creating trigger 2, you can mention in it's create statement that "follows trigger 1". In this way trigger 1 will be fired first and then trigger2.
    .
    But the best way will be to incorporate the logic in one trigger , as suggested to you by sb92075.
  • 3. Re: Triggers
    RajeshKanna Newbie
    Currently Being Moderated
    how to mention which trigger will first in create statement

    Edited by: RajeshKanna on Feb 12, 2013 9:18 PM
  • 4. Re: Triggers
    990622 Newbie
    Currently Being Moderated
    For your knowledge purpose , I am giving you the sample code.

    But again stressing, please follow the other way sugested to you.

    create table test_table ( col1 number);

    create or replace trigger trig1
    before insert on test_table
    for each row
    begin
    dbms_output.put_line ( 'Trig1 fired');
    end;
    /

    create or replace trigger trig2
    before insert on test_table
    for each row
    follows trig1
    begin
    dbms_output.put_line ( 'Trig2 fired');
    end;

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points