直接贴触发器具体实现:
create or replace trigger trg_update_versionnum
before update on t_order
for each row
begin
if (updating) and (:new.uploadtag1 = 0) then
:new.versionnum := :old.versionnum + 1;
end if;
end trg_update_versionnum;
说明:
1、目的:更新t_order表中的uploadtag1 为0的时候,同时需要触发更新t_order.versionnum 的值进行递增。
2、要点是before update在更新之前触发,仅仅把新值带入 :new.versionnum 进行设置。更新之后触发有问题,直接使用update t_order语句也会存在报错问题。
以上供大家参考学习。
也可参考网站:https://www.linuxidc.com/Linux/2013-07/87075.htm