gpt4 book ai didi

sql - PL/SQL更新触发错误

转载 作者:行者123 更新时间:2023-12-03 08:18:12 31 4
gpt4 key购买 nike

create or replace TRIGGER PRODUCT_REORDER_AU
AFTER UPDATE ON PRODUCT
FOR EACH ROW

BEGIN

IF (PRODUCT.QUANTITY_IN_STOCK < PRODUCT.REORDER_POINT)

THEN

INSERT INTO PURCHASE_ORDER
(PO_NO, PO_DATE, PRODUCT_ID, QUANTITY, SUPPLIER_ID)
VALUES
(OLD.PO_NO, NEW.PO_DATE, OLD.PRODUCT.PRODUCT_ID, OLD.PRODUCT.REORDER_QUANTITY, OLD.PRODUCT.SUPPLIER_ID);

END IF;
END;

我正在尝试创建一个用于更新操作的触发器,但遇到以下错误:
Error(8,1): PL/SQL: Statement ignored
Error(8,13): PLS-00357: Table,View Or Sequence reference 'PRODUCT.QUANTITY_IN_STOCK' not allowed in this context

最佳答案

我的猜测是您要检查:new.quantity_in_stock:new.reorder_point值。请记住,:new:old伪记录以冒号作为前缀。

IF (:new.QUANTITY_IN_STOCK < :new.REORDER_POINT)
THEN
INSERT INTO PURCHASE_ORDER
(PO_NO, PO_DATE, PRODUCT_ID, QUANTITY, SUPPLIER_ID)
VALUES
(:OLD.PO_NO, :NEW.PO_DATE, :OLD.PRODUCT_ID,
:OLD.REORDER_QUANTITY, :OLD.SUPPLIER_ID);
END IF;

关于sql - PL/SQL更新触发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22822865/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com