Can we have same trigger with different names for a table?eg: create trigger trig1after insert on tab1;andeg: create trigger trig2after insert on tab1;If yes,which trigger executes first.

Showing Answers 1 - 37 of 37 Answers

bibin

  • Feb 8th, 2007
 

Yes you can have . This is because the triggers dont share the same namespace for tables.whereas funtions,procedures,tables etc share the same namespace.so they cant have the same name

  Was this answer useful?  Yes

Nikhil_4_Oracle

  • Mar 7th, 2007
 

Hi all,

i think the Question is ask in wrong way,

--> create trigger trig1

--> create trigger trig2

(both
are diff triggers on same table tab1)

its always possible...since oracle allows 12 triggers/table.

but if
you trying to do,

create trigger trigg1

after insert on emp


**************

create trigger trigg1

after update on emp

then There is An Error,-->"trigg1 already exits".

since Triggers are Stored objects in oracle, like u r stored procedures and functions..

Regards,

Nikhil - i-flex


  Was this answer useful?  Yes

prabha0508

  • May 4th, 2007
 

Yes we can create trigger on same event with different names but cannot predict which trigger is executed.

 for example:
create or replace trigger trigg1
 before delete on emp
 begin
 raise_application_error(-20001,'Delete not allowed');
 end;

 create or replace trigger trigg2
 before delete on emp
 begin
 raise_application_error(-20001,'Deletion is not allowed');
 end;

SQL>  delete from emp;
 delete from emp
             *
ERROR at line 1:
ORA-20001: Deletion is not allowed
ORA-06512: at "SCOTT.TRIGG2", line 2
ORA-04088: error during execution of trigger 'SCOTT.TRIGG2'

Prabha Sharma

Ritesh

  • Jun 6th, 2007
 

Hi,
The triggers will be fired on the basis of TimeStamp of their creation in Data Dictionary. The trigger with latest timestamp will be fired at last.

Ritesh

We can have same trigger with different names for a table

The triggers will be fired on the basis of TimeStamp of their creation in Data Dictionary. The trigger with latest timestamp will be fired at last.


Regards,
Manish kumar

  Was this answer useful?  Yes

Yes, we can decide which trigger should fire first, if two triggers are defined with the same timing point. 

Eg: create trigger trig2
      after insert on tab1
      for each row
      FOLLOWS trig1;

      create trigger trig1
      after insert on tab1
      for each row;

Here trig2 will fire after trig1.
This is available on Oracle 11g onwards ONLY.

  Was this answer useful?  Yes

panky10

  • Apr 13th, 2009
 

Yes, you can very well have a trigger on a single table performing the same operation but with different names.

The trigger which has the latest timestamp will be executed first and then followed by the others in the order of their creation :)

samareshp

  • Apr 22nd, 2009
 

yes we can create the  Triggers,,

Firing sequence is inreverse order of creation

say ::
m trigger ---created last fires first.
 a trigger
 z trigger
 ttt trigger
 tt trigger-- created first fires last

  Was this answer useful?  Yes

Baji Shaik

  • Jun 5th, 2011
 

yes, we cant said upto 10g oracle server executes the triggers randomly,

but 11g we are having a feature follows clause,by using this we have to control the execution of triggers explicitly by the developer,

syntax:  create or replace trigger trig1
              after insert on tab1;

              create trigger trig2
               after insert  on tab1
               follows trig1

  Was this answer useful?  Yes

MURTHY

  • Sep 7th, 2011
 

the question is very nice.

yes we can have 2 triggers with same body but with different names.


ex: create trigger trg1
....................
...............................
end;

create trigger trg2
....................
...............................
end;
but the latest trigger will be executed first that means trg2 will execute first then trg1.



pls check it. and intimate me if any mistakes

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