Trigger for Update particular column

CREATE TABLE MEMBER(

EID number,

ENAME VARCHAR2(30),

SAL number,

COMM number,

CHANGEDATE timestamp);

 

insert into member values(1,'James',2000,400,sysdate);

insert into member values(2,'Roy',3000,400,sysdate);

CREATE OR REPLACE TRIGGER MEMBER_UPDATE

   BEFORE UPDATE OF SAL,COMM ON MEMBER

   REFERENCING NEW AS NEW OLD AS OLD

   FOR EACH ROW

BEGIN

    :NEW.CHANGEDATE:=sysdate;

END;

/

select * from member;

EID

ENAME

SAL

COMM

CHANGEDATE

1

James

2000

400

            2013-04-14 10:33

2

Roy

3000

400

2013-04-14 10:34

 

update member set sal=2500 where EID=1;

commit;

select * from member;

EID

ENAME

SAL

COMM

CHANGEDATE

1

James

2500

400

2013-04-14 10:47

2

Roy

3000

400

2013-04-14 10:34

update member set ENAME='Sunny' where EID=2;

 

commit;

select * from member;

EID

ENAME

SAL

COMM

CHANGEDATE

1

James

2000

400

2013-04-14 10:47

2

Sunny

3000

400

2013-04-14 10:34



Comments