CREATE OR REPLACE TRIGGER update_QOH
BEFORE INSERT ON ORDERLINE
FOR EACH ROW
DECLARE
QOH_PRODUCT PRODUCT.QOH%TYPE;
ORD_NO ORDERS.ORDER_NO%TYPE;
BEGIN
SELECT QOH INTO QOH_PRODUCT FROM PRODUCT
WHERE :old.product_no = :new.product_no;
SELECT ORDER_NO INTO ORD_NO FROM ORDERLINE
WHERE :old.order_no = :new.order_no;
IF (:new.QTY <= QOH_PRODUCT) THEN
UPDATE PRODUCT SET QOH = QOH_PRODUCT - :new.QTY;
ELSE
send_email(ord_no, 'Backorder');
INSERT INTO BACKORDER
VALUES (backorder_no_seq.NEXTVAL, :new.product_no, :new.qty, SYSDATE);
INSERT INTO PRODVENDOR
VALUES (po_no_seq.NEXTVAL, vendor_no, :new.product_no, vend_qty,
shipping_method, SYSDATE, NULL, NULL, NULL);
END IF;
END;
/
-------------------------------------------------------------------------------
Error(13,3): PL/SQL: SQL Statement ignored
Error(13,91): PL/SQL: ORA-00984: column not allowed here
--------------------------------------------------------------------------------
產品表(P_no,QOH等)柱這裏不允許
訂單行表(OL_no,QTY等)
延期交貨表(B_no,B_QTY等)
賣方表(V_no等)
我需要確保當客戶購買產品時,產品表中有足夠的QOH,如果有,產品中的QOH應該減少(更新)。如果沒有,發送電子郵件給客戶,更新延期交貨表,產品應從供應商處訂購。
謝謝,我試着改變賦值運算符,但我仍然收到如此多的錯誤。 – indolent 2011-04-12 03:01:36