--備貨檢驗選單后 回寫備貨狀態(tài)
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;
--備貨檢驗修改選單后 回寫備貨狀態(tài)
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;
--備貨檢驗刪除單據(jù)后 回寫備貨狀態(tài)
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;
以上所述是小編給大家介紹的Oracle觸發(fā)器實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!