Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question.
Asked: July 03, 2016 - 5:43 am UTC
Last updated: July 04, 2016 - 2:28 am UTC
Version: 11.o
Viewed 1000+ times
SQL> set serverout on SQL> declare 2 invalid_number exception; 3 x int; 4 begin 5 dbms_output.put_line('Start'); 6 7 select to_number('a') into x from dual; 8 end; 9 / Start declare * ERROR at line 1: ORA-01722: invalid number ORA-06512: at line 7 SQL> SQL> SQL> set serverout on SQL> declare 2 invalid_number exception; 3 x int; 4 begin 5 dbms_output.put_line('Start'); 6 7 select to_number('a') into x from dual; 8 exception 9 when invalid_number then 10 dbms_output.put_line('exception caught'); 11 end; 12 / Start declare * ERROR at line 1: ORA-01722: invalid number ORA-06512: at line 7 SQL> SQL> SQL> set serverout on SQL> declare 2 invalid_number exception; 3 x int; 4 begin 5 dbms_output.put_line('Start'); 6 7 select to_number('a') into x from dual; 8 exception 9 when standard.invalid_number then 10 dbms_output.put_line('exception caught'); 11 end; 12 / Start exception caught PL/SQL procedure successfully completed. SQL> SQL> SQL> set serverout on SQL> declare 2 invalid_number exception; 3 x int; 4 begin 5 dbms_output.put_line('Start'); 6 raise invalid_number; 7 select to_number('a') into x from dual; 8 exception 9 when standard.invalid_number then 10 dbms_output.put_line('standard exception caught'); 11 12 when invalid_number then 13 dbms_output.put_line('my exception caught'); 14 end; 15 / Start my exception caught PL/SQL procedure successfully completed. SQL>
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library