6.5. The Predefined Datatypes

The PLV package provides several centrally located, predefined datatypes. These elements are used throughout PL/Vision, but you can make use of them as well.

The two variables that are to be used as predefined datatypes are the following:

plsql_identifier VARCHAR2(100) := 'IRRELEVANT';
max_varchar2 VARCHAR2(32767) := 'IRRELEVANT';

Use the plsql_identifier variable whenever you need to declare a VARCHAR2 variable or constant that holds a PL/SQL identifier, such as a table name or column name or program name. Currently these names are limited to 30 characters. That may, however, change in the future and you will find errors popping up in your utilities if you declare variables like this:

v_table_name VARCHAR2(30);

Instead, use the predefined datatype as follows:

v_table_name PLV.plsql_identifier%TYPE;

Use the max_varchar2 variable whenever you need to declare a string variable to the maximum number of characters allowable in PL/SQL. Again, today that maximum size is 32,767, but this value may increase in the future. By relying on max_varchar2 in your declarations and parameter definitions, you (or the supplier of PL/Vision) can change the definition in one place and, with a compile, upgrade all your code.

Do you notice any conflict between the declarations of these predefined datatypes and the best practices I described earlier in this book? I have ...

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.