触发器中如何取消插入操作 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;
那就在触发器的
update bill set quantity=quantity+:new.quantity
where food_id=:new.food_id and bid=:new.bid;
代码段后面再写个delete语句删除掉重复记录吧。。。 ------解决方案-------------------- 楼主目前的做法是直接insert,然后用触发器判断是修改还是新增,难道不可以先判断是修改还是新增,然后再决定update还是insert么