Oracle触发器将新行视为插入和更新数据

时间:2013-07-02 07:23:03

标签: oracle

我们有“员工”表及其相应的“Employee_Audit”表

当我们尝试添加新行时,'Employee_Audit'表包含'insert'和'update'条目

我的触发器是:

create or replace
TRIGGER Employee_AUDIT_TRIGGER
BEFORE DELETE OR INSERT OR UPDATE
ON Employee FOR EACH ROW
BEGIN

IF INSERTING THEN

INSERT INTO Employee _AUDIT (OPERATION, ID, VERSION, NAME, TYPE) 
VALUES('INSERT',:NEW.ID,:NEW.VERSION,:NEW.NAME,:NEW.TYPE);

ELSIF DELETING THEN

INSERT INTO Employee _AUDIT (OPERATION, ID, VERSION, NAME, TYPE)
VALUES ('DELETE',:OLD.ID,:OLD.VERSION,:OLD.NAME,:OLD.TYPE);

ELSIF UPDATING THEN

INSERT INTO Employee _AUDIT (OPERATION, ID, VERSION, NAME, TYPE) 
VALUES('UPDATE',:NEW.ID,:NEW.VERSION,:NEW.NAME,:NEW.TYPE);
END IF;
END Employee_AUDIT_TRIGGER;

任何人都知道原因并且没有例外。

0 个答案:

没有答案