O'Reilly logo

Oracle® PL/SQL® Interactive Workbook, Second Edition by Elena Silvestrova, Benjamin Rosenzweig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required