Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trigger to Update in the same table.

CrackerJackMay 12 2009 — edited May 13 2009
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>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 10 2009
Added on May 12 2009
5 comments
26,586 views