GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  PL/SQL
Go To First  |  Previous Question  |  Next Question 
 PL/SQL  |  Question 147 of 241    Print  
Can we have same trigger with different names for a table?

eg: create trigger trig1
after insert on tab1;

and

eg: create trigger trig2
after insert on tab1;

If yes,which trigger executes first.

  
Total Answers and Comments: 10 Last Update: April 22, 2009     Asked by: joseph 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Ritesh
 
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

Above answer was rated as good by the following members:
manish.baehal
February 08, 2007 00:35:02   #1  
bibin        

RE: Can we have same trigger with different names for ...
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
 
Is this answer useful? Yes | No
February 09, 2007 17:03:45   #2  
geetha24 Member Since: March 2006   Contribution: 27    

RE: Can we have same trigger with different names for ...
Yes you can have..but you cannot predict the order of the execution.
 
Is this answer useful? Yes | No
March 07, 2007 01:46:10   #3  
Nikhil_4_Oracle        

RE: Can we have same trigger with different names for ...

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



 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
May 04, 2007 03:45:28   #4  
prabha0508        

RE: Can we have same trigger with different names for ...
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

 
Is this answer useful? Yes | No
June 06, 2007 05:11:59   #5  
Ritesh        

RE: Can we have same trigger with different names for ...
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

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
February 26, 2009 02:46:00   #6  
kperumal75 Member Since: September 2008   Contribution: 2    

RE: 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.
Yes we can. The same effect is produced twice.
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
April 05, 2009 10:27:51   #7  
manish.baehal Member Since: March 2009   Contribution: 2    

RE: 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.
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

 
Is this answer useful? Yes | No
April 06, 2009 22:31:25   #8  
nevinalencherry Member Since: April 2009   Contribution: 1    

RE: 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.
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.

 
Is this answer useful? Yes | No
April 13, 2009 03:40:53   #9  
panky10 Member Since: April 2009   Contribution: 1    

RE: 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.
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 :)

 
Is this answer useful? Yes | No
April 22, 2009 06:47:42   #10  
samareshp Member Since: April 2009   Contribution: 24    

RE: 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.
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

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape