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
Date: 1996/01/13
Message-ID: <4d99dt$inb_at_gaia.cc.gatech.edu>#1/1
Hi:
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