Oracle 11gR2,触发
我有一张表学生(身份证,姓名)
我有这个触发器:
CREATE OR REPLACE
TRIGGER TR_STUDENT
AFTER INSERT ON STUDENT
BEGIN
DBMS_OUTPUT.PUT_LINE('end of transaction');
END;
我想在表格中插入数据:
INSERT INTO student (name) VALUES ('djjjkt');
INSERT INTO student (name) VALUES ('doadkjf');
INSERT INTO student (name) VALUES ('djjodjfijt');
INSERT INTO student (name) VALUES ('dkdakmfakmf')
COMMIT;
我有以下结果:
1 line inserted
end of transaction
1 line inserted
end of transaction
1 line inserted
end of transaction
1 line inserted
end of transaction
COMMIT
我想要
1 line inserted
1 line inserted
1 line inserted
1 line inserted
end of transaction
COMMIT
你可以帮帮我吗?
感谢
答案 0 :(得分:0)
缺少ON COMMIT触发器的解决方法是使用带有ON COMMIT REFRESH的物化视图(MV)并向此MV添加触发器,如 How to define a trigger ON COMMIT in Oracle?。 MV可以在基表(Student)本身上,也可以在辅助表上,其中插入一行并立即通过基表AFTER STATEMENT触发器删除。
答案 1 :(得分:-1)