SQL> set serveroutput on
SQL>
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
11 THEN
12 dbms_output.put_line('Trying to divide by zero');
13 dbms_output.put_line(' Value of Num_a ' || Num_a);
14 dbms_output.put_line(' Value of Num_b ' || Num_b);
15 END;
16 /
Trying to divide by zero
Value of Num_a 6
Value of Num_b 0
PL/SQL procedure successfully completed.
SQL>