Oracle触发器实例代码

oracle触发器,用于选单后修改选单的表的触发动作。

--备货检验选单后 回写备货状态
create or replace trigger tri_tobaccostockinsert
after insert
on "tobaccostockquality"
for each row
begin
update "goodsstock" set "firstcheckstate"=-1 where "id"=:new."goodsstock_id";
end;
--备货检验修改选单后 回写备货状态
create or replace trigger tri_tobaccostockupdate
before update
on "tobaccostockquality"
for each row
begin
update "goodsstock" set "firstcheckstate"=decode(to_number(:new."auditstatus"),0,-1) where "id"=:new."goodsstock_id";
if :new."goodsstock_id"<>:old."goodsstock_id" then
update "goodsstock" set "firstcheckstate"=-1 where "id"=:old."goodsstock_id";
end if;
end;
--备货检验删除单据后 回写备货状态
create or replace trigger tri_tobaccostockdelete
before delete
on "tobaccostockquality"
for each row
begin
update "goodsstock" set "firstcheckstate"=-1 where "id"=:old."goodsstock_id";
end;

以上所述是www.887551.com给大家介绍的oracle触发器实例代码,希望对大家有所帮助

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐