6.6. The Predefined Constants

In addition to the predefined datatypes, the PLV package offers a set of constants that are used throughout PL/Vision. These constants define the type of input or output repository you want to use in a given situation. These constants are used in PLVio, PLVlog, and PLVexc. The input/output options in PL/Vision are shown in the following table.

DescriptionConstant
Database tabledbtab
PL/SQL tablepstab
Operating system filefile
VARCHAR2 stringstring
Standard outputstdout

For example, if you want to define the target repository of the PLVio package to be a PL/SQL table, you will issue this command:

SQL> exec PLVio.settrg (PLV.pstab);

If you want PLVlog to write its information to an operating system file, you will execute this command:

SQL> exec PLVlog.tofile;

which in turn sets the v_log_type variable to the PLV.file constant.

Sidebar 1. Special Notes on PLV

Once you build a package like this, you will find yourself constantly adding to it. Be careful not to throw in constants and programs that really do have a place in another, less generic package.

The boolstg, errm, and now functions of PLV can all be used from within SQL statements, since the package specification for PLV includes calls to the RESTRICT_REFERENCES pragma.

The errm function is a good example of how you can use a layer of your own PL/SQL code around native PL/SQL builtins (SQLERRM) to make the information more widely accessible (i.e., callable from within SQL statements).

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.