触发器中如何取消插入操作
桃芝妖妖 2013-04-12 08:10:25 create or replace
trigger trig_number
before INSERT ON bill
for each row
declare
pragma autonomous_transaction;
sbid NUMBER;
begin
select count(*) into sbid from bill where bid=:new.bid and food_id=:new.food_id;
if sbid<>0 then
update bill set quantity=quantity+:new.quantity
where food_id=:new.food_id and bid=:new.bid;
elsif sbid=0 then
null;
end if;
end;
存在问题:插入数据后,原有数据会更新,但会重复插入一条数据
我想请教的是:如何在条件sbid<>0成立时,完成更新并且能取消插入操作