Oracle触发器实例代码

网络编程 2021-07-05 16:08www.168986.cn编程入门
Oracle触发器,用于选单后修改选单的表的触发动作。接下来通过本文给大家分享Oracle触发器实例代码,需要的的朋友参考下吧

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

--备货检验选单后 回写备货状态
CREATE OR REPLACE TRIGGER tri_TobaoStockINSERT
after INSERT
ON "TobaoStockQuality"
FOR each ROW
BEGIN
UPDATE "GoodsStock" SET "FirstCheckState"=-1 WHERE "ID"=:NEW."GoodsStock_ID";
END;
--备货检验修改选单后 回写备货状态
CREATE OR REPLACE TRIGGER tri_TobaoStockUPDATE
before UPDATE
ON "TobaoStockQuality"
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_TobaoStockDELETE
before DELETE
ON "TobaoStockQuality"
FOR each ROW
BEGIN
UPDATE "GoodsStock" SET "FirstCheckState"=-1 WHERE "ID"=:OLD."GoodsStock_ID";
END;

以上所述是长沙网络推广给大家介绍的Oracle触发器实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,长沙网络推广会及时回复大家的。在此也非常感谢大家对狼蚁SEO网站的支持!

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by