Novel scenario of trigger mutation - take a look

From: badri <badri_at_cc.gatech.edu>
Date: 1996/01/13
Message-ID: <4d99dt$inb_at_gaia.cc.gatech.edu>#1/1


Hi:

        It is the favorite mutation question of triggers. I know the cause of the error, only I cannot figure out why I am violating it!

        I have a before insert or update trigger that does a select on the same table on which the trigger is fired from. I thought that I cannot update/do some action that causes my trigger to fire again - trigger mutation is only caused by multiple firing of the same trigger. Will select on the same table (same row included  or not included) also cause mutation? I am baffled!

        I enclose the skeleton text of my trigger for further details:

	Create trigger Mytrigger 
		before insert or update of col1,col2, col3
		on mytable
		declare
			nMyValue	NUMBER;
	for each row
	BEGIN
		if :NEW.col1>0 then
			/* This fires and works great */
			update someothertable set col4=1
			where col2=:OLD.col2;
		elsif
			:NEW.col1=0 then

/* This select mutates - Why? */
select sum(col1) into nMyValue from mytable where col2=:OLD.col2 and col3 != :OLD.col3;
/* I tried adding the second where
clause to exclude the current row and hope the trigger would not mutate, but it still does! */ if :nMyValue=0 then update someothertable set col4=0 where col2=:OLD.col2; end if; end if; end; /

Please help,

thanks a lot,

-Badri Received on Sat Jan 13 1996 - 00:00:00 CET

Original text of this message