Lab 7.1 Handling Errors

Lab Objectives

After this Lab, you will be able to:

Understand the Importance of Error Handling

The following example will help to illustrate some of the differences between compilation and runtime errors.

FOR EXAMPLE

DECLARE 
   v_num1 INTEGER := &sv_num1; 
   v_num2 INTEGER := &sv_num2; 
   v_result NUMBER; 
BEGIN 
   v_result = v_num1 / v_num2; 
   DBMS_OUTPUT.PUT_LINE ('v_result: '||v_result); 
END; 

This example is a very simple program. There are two variables, v_num1 and v_num2. A user supplies values for these variables. Next, v_num1 is divided by v_num2, and the result of this division is stored in the third variable, v_result. Finally, the value of v_result is displayed on the screen.

Now, assume that a user supplies values ...

Get Oracle® PL/SQL® Interactive Workbook, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.