Tuesday, June 19, 2018

When you perform update or delete operation on table company1, stores the updated or deleted values in table company2. Also show the operation ‘update’ and ‘delete’ and username. Table : Company1(no, name) Company2(no, name, operation, username) - DBMS (Trigger)


CREATE OR REPLACE TRIGGER t2
after update or delete ON company1
for each row
BEGIN
Select user into username from dual;
if updating then
insert into company2 values(:new.no,:new.name,'update',username);
end if;
if deleting then
insert into company2 values(:old.no,:old.name,'delete',username);
end if;
END;

No comments:

Post a Comment