tags:

views:

24

answers:

1

I want to update the same record using the trigger which fires due to insertion of that record.

When I try to do that using the following code it gives an error

DROP TRIGGER CONTROLLER_UPLOADER;

CREATE OR REPLACE TRIGGER CONTROLLER_UPLOADER

after insert ON CONTROLLER for each row

begin

    UPDATE CONTROLLER SET STATUS = 'STARTED' WHERE ID = (SELECT MAX(ID) FROM CONTROLLER);

end;
+3  A: 
DROP TRIGGER CONTROLLER_UPLOADER;

CREATE OR REPLACE TRIGGER CONTROLLER_UPLOADER

BEFORE insert ON CONTROLLER for each row

begin

    :NEW.STATUS := 'STARTED';

end;

Note "BEFORE" not "AFTER".

Tony Andrews