Re: 'insert or update trigger' to update the same table

From: (wrong string) æk <znake_at_lazy.dk>
Date: Fri, 02 Nov 2001 08:29:09 GMT
Message-ID: <20011102.8290915_at_mis.configured.host>


You have to state your goal more precise. If you only intent to update the current record (i.e. The record

already being procesed in the trigger) then dont use sql-statement, but

only normal plsql-code.
Simply set
if (:new.status = true ) then
:new.desc = =to char(sysdate);
end if;

(I take that the serial is a unique key simply is eferring to the record  

already being processed in the trigger)
If you really want to update other records (than the actual one being

processed) in a trigger then you must use a whole diferent approach.

>>>>>>>>>>>>>>>>>>  <<<<<<<<<<<<<<<<<<
 

> Hi!
 

> Maybe it's just a simple problem for some of you, but I really
> desparate to find the solution.
 

> This is my trigger
 

> CREATE OR REPLACE TRIGGER OBJ
 
> BEFORE INSERT OR UPDATE ON OBJ
 
> FOR EACH ROW
 
> BEGIN
> update OBJ
> set OBJ.DESCR=to char(sysdate)
> where status=true and serial=:new.serial
> END;

> I get an error that the table is mutating.
> I know the reason of this error, but I can't find any other solution.
 

> I think I have to use row level trigger since I have to know the
> serial from the row which is updated or inserted.
 

> I've tried to create a view and then an INSTEAD OF TRIGGER, but I
> always get an error which said that my trigger is invalid (I use TOAD
 

> to write my trigger)
 

> Thank you in advance!!
 

> sien
Received on Fri Nov 02 2001 - 09:29:09 CET

Original text of this message