An inquiry directive is a directive that makes an inquiry of the compilation environment. Of course, that doesn’t really tell you much. So let’s take a closer look at the syntax for inquiry directives and the different sources of information available through the inquiry directive. The syntax for an inquiry directive is as follows: $$identifier where identifier is a valid PL/SQL identifier that can represent any of the following:
Inquiry directives are designed for use within conditional compilation clauses, but they can also be used in other places in your PL/SQL code. For example, I can display the current line number in my program with this code: DBMS_OUTPUT.PUT_LINE ($$PLSQL_LINE); I can also use inquiry directives to define and apply application-wide constants in my code. Suppose, for example, that the maximum number of years of data supported in my application is 100. Rather than hardcode this value in my code, I could do the following: ALTER SESSION SET PLSQL_CCFLAGS = 'max_years:100'; CREATE OR REPLACE PROCEDURE work_with_data (num_years_in IN PLS_INTEGER) Even more valuable, I can use inquiry directives in places in my code where a variable is not allowed. Here are two examples: DECLARE l_default_app_err EXCEPTION; The DBMS_DB_VERSION package The DBMS_DB_VERSION built-in package offers a set of constants that give you absolute and relative information about the version of your installed database. The constants defined in the Oracle Database 10g Release 2 version of this package are shown in Table 20-2. Table 20-2. DBMS_DB _VERSION constants
Table 20-2. DBMS_DB _VERSION constants (continued) Name of packaged constant Significance Value in Oracle Database 10g Release 2 DBMS_DB_VERSION.RELEASE The RDBMS release number, as in 2 for Oracle Data-base 10gRelease 2 2 DBMS_DB_VERSION.VER_LE_9 TRUE if the current version is less than or equal to Oracle9iDatabase FALSE DBMS_DB_VERSION.VER_LE_9_1 TRUE if the current version is less than or equal to Oracle9iDatabase Release 1 FALSE DBMS_DB_VERSION.VER_LE_9_2 TRUE if the current version is less than or equal to Oracle9iDatabase Release 2 FALSE DBMS_DB_VERSION.VER_LE_10 TRUE if the current version is less than or equal to Oracle Database 10g TRUE DBMS_DB_VERSION.VER_LE_10_1 TRUE if the current version is less than or equal to Oracle Database 10g Release 1 FALSE DBMS_DB_VERSION.VER_LE_10_2 TRUE if the current version is less than or equal to Oracle Database 10gRelease 2 TRUE While this package was designed for use with conditional compilation, you can, of course, use it for your own purposes. With each new release of the database, Oracle will add additional constants and will update the values returned by the VERSION and RELEASE constants. Interestingly, you can write expressions that include references to as-yet undefined constants in the DBMS_DB_VERSION package. As long as they are not evaluated, as in the case below, they will not cause any errors. Here is an example: $IF DBMS_DB_VERSION.VER_LE_10_2
blog comments powered by Disqus |
|
|
|
|
|
|
|