15.2. Displaying Compile Errors

The err procedure of the PLVvu package offers a very useful alternative to the SQL*Plus SHOW ERRORS command. The header for this procedure is:

PROCEDURE err 
   (name_in IN VARCHAR2 := NULL, overlap_in IN INTEGER := overlap);

You provide the name of the program unit for which you want errors displayed and the err procedure not only displays all errors found in the USER_ERRORS view, but it also shows you exactly which lines of code are causing the problem. The second argument specifies the numbers of lines of code to display around the line with the compile error. The default value is the value set by the set_overlap procedure (described in a later section).

If you do not supply a program name, PLVvu.err will show you the compile errors for the most recently-compiled program unit. It determines this information by searching for the object in ALL_OBJECTS whose last_ddl_time equals the MAX (last_ddl_time).

The format for specifying a program unit is explained fully in Chapter 11. Briefly, you can supply only the name, the type:name (as in "b:PLVio" for the body of the PLVio package), or even the type:schema.name (as in "s:scott.showemps" to see the specification of the showemps package owned by SCOTT).

The err procedure tries to be smart about displaying the surrounding lines of code. Suppose, for example, that you have errors on two consecutive lines (318 and 319) and you have specified 10 lines of overlap. You would not want to see lines 309 through ...

Get Advanced Oracle PL/SQL Programming with Packages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.