truncate table output / ------------------------------------------------------------------------------------------ -- Creating a trigger ------------------------------------------------------------------------------------------ CREATE or replace TRIGGER log_update BEFORE INSERT OR UPDATE OR DELETE ON student FOR EACH ROW DECLARE v_id number; BEGIN IF :OLD.student_id is not null THEN v_id := :OLD.student_id; ELSE v_id := :NEW.student_id; END IF; insert into output values('id-' || v_id || ' changed from '|| :OLD.student_id ||' to '|| :NEW.student_id); insert into output values('id-' || v_id || ' fname changed from '|| :OLD.fname ||' to '|| :NEW.fname); insert into output values('id-' || v_id || ' lname changed from '|| :OLD.lname ||' to '|| :NEW.lname); insert into output values('id-' || v_id || ' ssn changed from '|| :OLD.ssn ||' to '|| :NEW.ssn); insert into output values('id-' || v_id || ' sex changed from '|| :OLD.sex ||' to '|| :NEW.sex); END; / insert into student values(33,'Potter','Harry','123456789','M') / update student set ssn='123-12-1235' where student_id=33 / delete from student where student_id=33 / select * from output / drop trigger log_update