自定义异常-错误码SQLCODE-错误信息SQLERRM-raise_application_error(SQLCODE,SQLERRM)
/* Formatted on 2012/02/21 18:42 (Formatter Plus v4.8.7) */
DECLARE
org_id NUMBER := -1;
excp_org_id_error EXCEPTION;
PRAGMA EXCEPTION_INIT (excp_org_id_error, -20001);
BEGIN
IF org_id < 0
THEN
raise_application_error (-20001, 'org_id should be greater than 0!');
END IF;
EXCEPTION
WHEN excp_org_id_error
THEN
DBMS_OUTPUT.put_line ('ORA' || SQLCODE || ':' || SQLERRM);
END;
DBMS Output:
ORA-20001:ORA-20001: org_id should be greater than 0!