Trigger to Update in the same table.
Hi,
I would like to create a trigger that when we insert into table ALL_CAPACITY_SNS_CELL1 it updates column Action on teh same table,if teher is an update, it will update the same table , column ACTION.
This is what I have attempted but seems to be technically wrong.
<pre>
create table ALL_CAPACITY_SNS_CELL1
( A varchar2,
action char(2),
date_executed date);
create or replace
TRIGGER ALL_CAPACITY_HISTORY_TRACKING
AFTER INSERT OR DELETE OR UPDATE ON ALL_CAPACITY_SNS_CELL1 FOR EACH ROW
DECLARE
v_operation VARCHAR2(10) := NULL;
BEGIN
IF INSERTING THEN
v_operation := 'I';
ELSIF UPDATING THEN
v_operation := 'U';
ELSE
v_operation := 'D';
END IF;
IF INSERTING
UPDATE ALL_CAPACITY_SNS_CELL1
SET ACTION =v_operation,
DATE_EXECUTED =sysdate ;
ELSIF UPDATING THEN
UPDATE ALL_CAPACITY_SNS_CELL1
SET ACTION =v_operation,
DATE_EXECUTED =sysdate ;
END IF;
END;
</pre>