- 
	
	
		
			
			
				Junior Member
			
			
			
			
				
					
						  
 
					    
				 
 
			
				
				
				
					mutating trigger
				
					
						
							hi everybody
 can anyone explain me what is mutating trigger.
 
 
 
 
 
 
 
 
 
- 
	
	
		
			
			
				Contributing Member
			
			
			
			
				
					
						  
 
 
			
				
				
				
					Re: mutating trigger
				
					
						
							Hi, a mutating trigger occurs in oracle when the table that originally fired the triggering event is being accessed in the body of the trigger code, directly or implicitly in a procedure, or in a nested trigger called from the trigger body.
 
 This action is forbidden because the table is in middle of a transaction, and referencing the same table again in the middle of the updating action causes the trigger to mutate. For example:
 
 sql>create table t1 (x int);
 
 sql>create table t2 (x int);
 
 sql>insert into t1 values (1);
 
 sql>select * from t1;
 
 sql>select * from t2;
 
 sql>create or replace trigger t_trigger
 
 after insert on t1
 
 for each row
 
 declare
 
 i pls_integer;
 
 begin
 
 select count(*) into i from t1;
 
 insert into t2 values (i);
 
 end; /
 
 sql>insert into t1 values (1);
 
 sql>select count(*) from t1;
 
 sql>select count(*) from t2;
 
 if u run this one u will get the mutating error, ora-04091.
 
 Cheers, regards
 
 rsy
 
 
 
 
 
 
				
				
				
					
						Last edited by raghav_sy; 02-08-2007 at 02:57 AM.
					
					
						Reason: code formatting was lost..........
					
				 
 
 
 
 
 
	
	
	
	
	
	
	
	
	
	
	
	
		
		
			
				 Posting Permissions
				Posting Permissions
			
			
				
	
		- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-  
Forum Rules