| Error ORA-04091 [message #598399] | 
			Mon, 14 October 2013 09:45   | 
		 
		
			
				
				
				  | 
					
						
						andreacaffy
						 Messages: 5 Registered: October 2013 
						
					 | 
					Junior Member  | 
					 | 
		 
		 
	 | 
 
	
		I have a problem: i receive this error. 
table TableName is mutating, trigger/function may not see it. 
 
The problem is that I try to execute a stored procedure extracting data from the same table. 
 
My table have a trigger before on insert for each row 
begin
  :new.pl_id := ppe_seq_pl_id.nextval;
end;
/
  
 
where ppe_seq_pl_id is a sequence. 
 
I read that is possible to resolve that problem creating a Package. But I try withouth success. 
Can you help me? 
 
 
 
		
		
		
 |  
	| 
		
	 | 
 
 
 | 
	
		
		
			| Re: Error ORA-04091 [message #598404 is a reply to message #598399] | 
			Mon, 14 October 2013 10:06    | 
		 
		
			
				
				
				
					
						
						Lalit Kumar B
						 Messages: 3174 Registered: May 2013  Location: World Wide on the Web
						
					 | 
					Senior Member  | 
					 | 
		 
		 
	 | 
 
	
		What are you doing in the procedure? When you have a trigger on a table you cannot do SELECT on the table inside the trigger.  
 
Post the complete trigger code and what you are doing inside the procedure. 
 
		
		
		[Updated on: Mon, 14 October 2013 10:06] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	
		
		
			| Re: Error ORA-04091 [message #598405 is a reply to message #598399] | 
			Mon, 14 October 2013 10:12    | 
		 
		
			
				
				
				  | 
					
						
						andreacaffy
						 Messages: 5 Registered: October 2013 
						
					 | 
					Junior Member  | 
					 | 
		 
		 
	 | 
 
	
		In my procedure I need to insert many rows than the values of Field1 
 
scen, dat, descr are string.  
CALC_TOTAL_ACC and CALC_MONTH_LENGHT are functions 
idinput is a parameter passed to the procedure 
 
INSERT INTO TableRows (R_ID, Field1, Field2, Field3, Field4, Field5, Field6, Field7, Total1, Total2, Field8)
SELECT R_ID, FIEDL1, scen, dat, dat, '-','','Actual',case when 0.8*CALC_TOTAL_ACC(idinput,'Budget',field1)/CALC_MONTH_LENGTH(idinput) < 0 then 
		0 else 0.8*CALC_TOTAL_ACC(idinput,'Budget',field1)/CALC_MONTH_LENGTH(idinput) end,
		case when 0.8*CALC_TOTAL_ACC(idinput,'Budget',field1)/CALC_MONTH_LENGTH(idinput) < 0 
		then 0.8*CALC_TOTAL_ACC(idinput,'Budget',field1)/CALC_MONTH_LENGTH(idinput) else 0 end
		, descr FROM TableRows WHERE R_ID=idinput GROUP BY Field1, R_ID;  
		
		
		
 |  
	| 
		
	 | 
 
 
 | 
	
		
		
			| Re: Error ORA-04091 [message #598409 is a reply to message #598405] | 
			Mon, 14 October 2013 10:31    | 
		 
		
			
				
				
				  | 
					
						
						andreacaffy
						 Messages: 5 Registered: October 2013 
						
					 | 
					Junior Member  | 
					 | 
		 
		 
	 | 
 
	
		
CREATE OR REPLACE TRIGGER TRIGGERNAME BEFORE INSERT ON TableRows REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
begin
  :new.id := seq_id.nextval;
end;
/
  
 
and the sequence 
 
CREATE SEQUENCE SEQ_ID
  START WITH 2155430
  MAXVALUE 9999999999999999999999999999
  MINVALUE 1
  NOCYCLE
  CACHE 20
  ORDER;
  
		
		
		[Updated on: Mon, 14 October 2013 10:32] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 | 
	| 
		
 | 
	| 
		
 | 
	| 
		
 |