开始
SET SERVEROUTPUT ON; DECLARE v_ename emp.ename%TYPE; e_norecord EXCEPTION; PRAGMA EXCEPTION_INIT (e_norecord, -20001); err_num NUMBER; err_msg VARCHAR2(100); BEGIN SELECT ename INTO v_ename FROM emp WHERE empno=3000; EXCEPTION WHEN OTHERS THEN err_num := SQLCODE; err_msg := SUBSTR(SQLERRM, 1, 100); DBMS_OUTPUT.PUT_LINE(err_num||'----'||err_msg); END;
运行结果:
anonymous block completed 100----ORA-01403: no data found
结束
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/11/23/2784451.html,如需转载请自行联系原作者