【发布时间】:2014-09-18 12:24:09
【问题描述】:
我有两张桌子
user_salary
-------------------------
| user_id | salary_p |
-------------------------
| 1 | 100 |
| 2 | 200 |
-------------------------
user_p_salary
------------------------
| user_id | salary_c |
-------------------------
| 1 | 100 |
| 2 | 200 |
-------------------------
user_salary 是通过 UI 使用的,它有以下触发器:
create or replace trigger t$user_salary_aiu
after insert or update of salary_p
on user_salary
for each row
begin
update user_p_salary t
set t.salary_c = :new.salary_p,
where t.user_id = :new.user_id
end t$user_salary_aiu;
user_p_salary 通过集成获取数据,代码如下:
create or replace trigger t$user_p_salary_aiu
after insert or update of salary_c
on user_p_salary
for each row
begin
update user_salary t
set t.salary_p = :new.salary_c,
where t.user_id = :new.user_id
end t$user_p_salary_aiu;
现在的问题是,如果其中一个表获取数据,那么它会执行触发器并更新另一个表中的数据。但是,另一个表上的触发器也会执行..这就像触发器的循环。
唯一的方法是使用 execute immediate 'alter triggername disable' 但这似乎根本不适用于触发器。有什么想法吗?
提前致谢:-)
【问题讨论】:
-
我很惊讶您没有收到 ORA-04091 错误。你在使用自主交易吗?
-
是的,我收到 ORA-04901 错误
标签: oracle plsql oracle11g plsqldeveloper