0

我有以下带有异常块的过程。当我执行此过程时,系统正在捕获错误而不是我的异常块。任何人都对我做错了什么有任何想法。谢谢

    CREATE OR REPLACE PROCEDURE ADD_ORDER
       (CUST_NUM IN CUSTOMERS_T_P2.CNO%TYPE,
       EMP_NUM IN EMPLOYEE_T_P2.ENO%TYPE,
       REC_DATE IN  ORDERS_T_P2.RECEIVED%TYPE)
     IS
     BEGIN
     IF REC_DATE IS NULL THEN
       INSERT INTO ORDERS_T_P2 (ONO, CNO, ENO, RECEIVED)
        VALUES
          (ORDER_NUMBER_SEQ.NEXTVAL, CUST_NUM, EMP_NUM, SYSDATE);
     ELSE 
        INSERT INTO ORDERS_T_P2 (ONO, CNO, ENO, RECEIVED)
          VALUES
           (ORDER_NUMBER_SEQ.NEXTVAL, CUST_NUM, EMP_NUM, REC_DATE);
     END IF;

    EXCEPTION
    WHEN VALUE_ERROR THEN
       ROLLBACK WORK;
         INSERT INTO ORDER_ERRORS_T_P2 
          VALUES
          (ORDER_NUMBER_SEQ.NEXTVAL, SYSDATE, 'STRING WAS ENTERED INSTEAD OF NUMBER');
             DBMS_OUTPUT.PUT_LINE('STRING WAS ENTERED INSTEAD OF NUMBER');
       END;
4

1 回答 1

0

VALUE_ERROR 应该在 DECLARE 块中声明为异常

CREATE OR REPLACE PROCEDURE ADD_ORDER
       (CUST_NUM IN CUSTOMERS_T_P2.CNO%TYPE,
       EMP_NUM IN EMPLOYEE_T_P2.ENO%TYPE,
       REC_DATE IN  ORDERS_T_P2.RECEIVED%TYPE)
     IS
VALUE_ERROR EXCEPTION;

     BEGIN
---------------
于 2013-07-05T21:36:52.793 回答