SQL> set serveroutput on
SQL> DECLARE
2 Num_a NUMBER := 6;
3 Num_b NUMBER;
4 BEGIN
5 Num_b := 0;
6 Num_a := Num_a / Num_b;
7 Num_b := 7;
8 dbms_output.put_line(' Value of Num_b ' || Num_b);
9 EXCEPTION
10 WHEN ZERO_DIVIDE THEN
11 DECLARE
12 err_num NUMBER := SQLCODE;
13 err_msg VARCHAR2(512) := SQLERRM;
14 BEGIN
15 dbms_output.put_line('ORA Error Number ' || err_num );
16 dbms_output.put_line('ORA Error message ' || err_msg);
17 dbms_output.put_line(' Value of Num_a is ' || Num_a);
18 dbms_output.put_line(' Value of Num_b is ' || Num_b);
19 END;
20 END;
21 /
ORA Error Number -1476
ORA Error message ORA-01476: divisor is equal to zero
Value of Num_a is 6
Value of Num_b is 0
PL/SQL procedure successfully completed.
SQL>