SET SERVEROUTPUT ON BEGIN -- 逻辑代码 ... EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('SQLCODE:' || SQLCODE || ' SQLERRM:' || SQLERRM); END;
SET SERVEROUTPUT ON BEGIN DBMS_OUTPUT.PUT_LINE('NUM:' || TO_NUMBER('AAAA')); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM); END;
SET SERVEROUTPUT ON BEGIN FOR i IN 1..9 LOOP BEGIN DBMS_OUTPUT.PUT_LINE('item:' || i); DBMS_OUTPUT.PUT_LINE('NUM:' || TO_NUMBER('AAAA')); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM); END; END LOOP; END;
-- 参数1为错误编码,取值范围:-20000到-20999,参数2为自定义的错误信息 RAISE_APPLICATION_ERROR(-20000, '自定义异常!');