U kunt veel voorbeelden van triggers vinden in Oracle-documentatie. Wat u nodig hebt, is na invoegen, bijwerken en verwijderen voor elke rijtriggers om uw logtabellen te vullen. Hier is een voorbeeld uit Oracle-documenten:
http://docs.oracle.com/cd /B28359_01/appdev.111/b28370/triggers.htm#LNPLS020
CREATE TABLE Emp_log (
Emp_id NUMBER,
Log_date DATE,
New_salary NUMBER,
Action VARCHAR2(20));
CREATE OR REPLACE TRIGGER Log_salary_increase_ARUID
AFTER UPDATE OR INSERT OR DELETE ON emp
FOR EACH ROW
BEGIN
-- Can be separated for Inserting then Updating with addl if
-- In this case it may be easier to control and/or add flags to your log tables
-- such as Action = 'INS' or Action = 'UPD' --
If (INSERTING OR UPDATING)
THEN
-- Insert newly created/updated values to your log table --
INSERT INTO Emp_log (Emp_id, Log_date, New_salary, Action)
VALUES (:NEW.Empno, SYSDATE, :NEW.SAL, 'INS_UPD');
ELSE
-- Deleting - insert old or deleted values to your logs --
INSERT INTO Emp_log (Emp_id, Log_date, New_salary, Action)
VALUES (:OLD.Empno, SYSDATE, :OLD.SAL, 'DEL');
END;
/