我有一张桌子叫M_InventoryLine
M_InventoryLine
M_Product_ID || QtyEntered
101 || 50
M_Replenish
M_Product_ID || Level_Min
101 || 20
VW_DaftarBarang_Available
M_Product_ID || Available
101 || 35
QtyEntered
不能超过Available
+Level_Min
所以,我需要Raise Application Error
在触发器中。
我试过像这样制作触发器:
CREATE OR REPLACE TRIGGER SAVE_ERROR
BEFORE INSERT OR UPDATE ON M_INVENTORYLINE
FOR EACH ROW
DECLARE
AVAILABLE_ST NUMBER;
MIN_LEVEL NUMBER;
BEGIN
SELECT AVAILABLE INTO AVAILABLE_ST
FROM vw_daftarbarang_available
where m_product_id = :new.m_product_id;
SELECT LEVEL_MIN INTO MIN_LEVEL
FROM M_REPLENISH
WHERE M_PRODUCT_ID = :NEW.M_PRODUCT_ID;
IF :NEW.QTYENTERED > :OLD.AVAILABLE + :OLD.MIN_LEVEL THEN
RAISE_APPLICATION_ERROR(-20000,'QUANTITY IS NOT ENOUGH');
END IF;
END;
但它不起作用。有什么建议可以成功触发吗?