【发布时间】:2014-04-30 14:21:51
【问题描述】:
嗨,我有这个触发器
create or replace TRIGGER trg_cust
after insert or update on nbty_customer
referencing old as old new as new
for each row
declare
pragma autonomous_transaction;
V_REQ VARCHAR2(10);
begin
IF(:NEW.cust_sal<1000)
THEN
select :NEW.cust_sal+:OLD.cust_sal INTO V_REQ FROM nbty_customer
where cust_id=:old.cust_id;
ELSE
SELECT :NEW.cust_sal-:OLD.cust_sal INTO V_REQ FROM nbty_customer where cust_id=:old.cust_id;
end if;
merge into nbty_cache_cust
using
(select distinct :new.cust_id cust_id, :new.cust_name cust_name,V_REQ V_REQ
from nbty_customer) b
on (cust_nbty_id = b.cust_id)
when matched then
update set cust_nbty_name = b.cust_name, cust_nbty_sal = b.V_REQ
when not matched then
insert (cust_nbty_id, cust_nbty_name, cust_nbty_sal)
values (b.cust_id, b.cust_name, b.V_REQ);
commit;
end;
哪个编译正确,但是当在表 nbty_customer 上完成插入时,例如
insert into nbty_customer values('2','abc','200')
在执行触发器时抛出 ora-01403 no data found 错误,ora-04088 错误 请帮忙,我无法弄清楚问题是什么?
【问题讨论】:
-
没有数据我们无法判断。事实是,有一个
select没有产生任何结果,你没有抓住。