HomeОбразованиеRelated VideosMore From: YourSmartCode

Tutorial 15 : DML TRIGGER || How to use TRIGGER to audit the table.

1 ratings | 121 views
Hi Friends, Here we are learning about, how we can use TRIGGER to audit the table. Hope the example will give a brief vision about TRIGGER. Please let me know your confusion or doubt in comment box. Thanks. Happy Coding :)
Html code for embedding videos on your blog
Text Comments (2)
Deepak Kumar (11 months ago)
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
YourSmartCode (11 months ago)
Hi Deepak... thanks for the comment... Your mistake is there in 4th statement,, ELSIF DELETING THEN. The INSERT Query is not properly written. Please check below query, ELSIF DELETING THEN INSERT INTO emp_audit (new_name, old_name, created_on, operation) VALUES (:NEW.NAME, :OLD.NAME, v_date, 'delete'); Hope you got the correction.

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.