CREATE OR REPLACE TRIGGER biud_Emp1 BEFORE INSERT OR UPDATE OR DELETE ON Emp1 FOR EACH ROW DECLARE v_date varchar2(100); BEGIN SELECT SYSDATE INTO v_date FROM DUAL; IF inserting then insert into emp_Audit(new_Name, Old_Name, created_on, operation) VALUES (:new.name, null, v_date, 'insert'); elsif updating then insert into emp_Audit(new_Name, Old_Name, created_on, operation) VALUES (:new.name, :OLD.name, v_date, 'update'); elsif deleting then insert into emp_Audit(new.Name, Old_Name, created_On, Operation) VALUES(null, :OLD.Name, v_date, 'delete'); END IF; END; ** Can u check, where I did mistake
Your Presentation is very helpful .. Thanks.
Before trigger means the trigger is fired before inserting table is it correct sir
CREATE OR REPLACE TRIGGER biud_Emp1
BEFORE INSERT OR UPDATE OR DELETE ON Emp1
FOR EACH ROW
DECLARE
v_date varchar2(100);
BEGIN
SELECT SYSDATE INTO v_date FROM DUAL;
IF inserting then
insert into emp_Audit(new_Name, Old_Name, created_on, operation)
VALUES (:new.name, null, v_date, 'insert');
elsif updating then
insert into emp_Audit(new_Name, Old_Name, created_on, operation)
VALUES (:new.name, :OLD.name, v_date, 'update');
elsif deleting then
insert into emp_Audit(new.Name, Old_Name, created_On, Operation)
VALUES(null, :OLD.Name, v_date, 'delete');
END IF;
END;
** Can u check, where I did mistake