The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
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