Oracle数据库TRIGGER在某些情况下不起作用
Oracle 数据库有一个包含多个列的表,其中 1 个列名为 DATEMODIFIED。 当我通过脚本更新表时:
UPDATE TABLE1
SET AMOUNT = 10
WHERE ID IN (3,4,5,6,7);
COMMIT;
然后,名为 DATEMODIFIED 的日期列将自动更新。 我可以找到触发代码如下:
CREATE OR REPLACE TRIGGER SET_TABLE1_DATEMODIFIED
BEFORE UPDATE ON TABLE1 FOR EACH ROW
BEGIN
:NEW.DATEMODIFIED := SYSDATE;
END;
但是,我可以找到 AMOUNT 值已更新的多个实例,而不会触发 DATEMODIFIED 中的更改。 Oracle系统如何实现这样的改变呢?是否有查询可以修改数据库值而不考虑 TRIGGER 语句?
The Oracle database has a table with multiple columns, with 1 column named DATEMODIFIED.
When I update the table via script:
UPDATE TABLE1
SET AMOUNT = 10
WHERE ID IN (3,4,5,6,7);
COMMIT;
Then the date is column named DATEMODIFIED would be updated automatically.
I can find the trigger code as follows:
CREATE OR REPLACE TRIGGER SET_TABLE1_DATEMODIFIED
BEFORE UPDATE ON TABLE1 FOR EACH ROW
BEGIN
:NEW.DATEMODIFIED := SYSDATE;
END;
However, I can find multiple instances that the AMOUNT value was update, without triggering a change in DATEMODIFIED. How can the Oracle system achieve such change? Are there anyway query can amend database values disregarding TRIGGER statements?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最有可能的是以下选项之一
lastModified
设置为null
当然,也有可能您没有准确识别
金额
更新的情况。例如,也许某人或某事删除了该行并重新插入它,而不是进行实际的更新
。Most likely, one of the following options
lastModified
tonull
Of course, there is also the possibility that you are not accurately identifying cases where the
amount
was updated. For example, perhaps someone or something deleted the row and re-inserted it rather than doing an actualupdate
.我可以考虑的几个选项:
INSERT INTO
不会触发amount
值之后创建的触发器已更新(因此没有要触发的触发器)amount
值之前禁用/删除触发器,然后启用/重新创建Several options I can think about:
INSERT INTO
wouldn't fire itamount
values were updated (so there were no triggers to be fired)amount
values were updated, and then enabled / recreated