I have the following trigger written, and am getting an error i don't understand.... the error I'm getting is :
Error report - SQL Error: ORA-00036: maximum number of recursive SQL levels (50) exceeded ORA-00036: maximum number of recursive SQL levels (50) exceeded
how would this be?
i didn't intend to do any recursion, is it because my select statement is to vague? create or replace TRIGGER INVENTORY_AVAIL Before INSERT ON TORDER FOR EACH ROW
DECLARE
v_quantity_diff number;
v_onhand_quantity number;
BEGIN
-- TRIGGR ON THIS...
--INSERT INTO ORDER
--( FK_ORDER_NO, FK_PROD_ID, QUANITY , COMPLETE_STATUS)
--VALUES
--( :NEW.FK_ORDER_NO, :NEW.FK_PROD_ID, :NEW.QUANITY , :NEW.COMPLETE_STATUS);
SELECT INVENTORY_ONHAND INTO v_onhand_quantity
FROM INVENTORY
WHERE :NEW.fk_prod_id = INVENTORY.FK_PROD_ID;
IF( (v_onhand_quantity - :NEW.QUANTITY) >= 0)
THEN
INSERT INTO ORDER ( FK_ORDER_NO, FK_PROD_ID, QUANTITY, COMPLETE_STATUS)
VALUES ( :NEW.FK_ORDER_NO, :NEW.FK_PROD_ID, :NEW.QUANTITY , :NEW.COMPLETE_STATUS);
ELSE
raise_application_error (-20001,'ERROR: QUANTITY ' || :NEW.QUANTITY
|| ' EXCEEDS INVENTORY ONHAND [' || TO_CHAR(v_onhand_quantity) || ']' );
END IF;
END;