An inquiry directive provides information about the compilation environment.
Syntax
$$name
An inquiry directive typically appears in the boolean_static_expression of a selection directive.
The predefined inquiry directives are:
Inquiry Directives | Description |
---|---|
$$PLSQL_LINE | A PLS_INTEGER literal whose value is the number of the source line on which the directive appears in the current PL/SQL unit. For example: $IF $$PLSQL_LINE = 32 $THEN ... |
$$PLSQL_UNIT | A VARCHAR2 literal that contains the name of the current PL/SQL unit. If the current PL/SQL unit is an anonymous block, $$PLSQL_UNIT contains a NULL value. For example: $IF $$PLSQL_UNIT IS NULL $THEN ... |
$$plsql_compilation_parameter | The name plsql_compilation_parameter is a PL/SQL compilation parameter (for example, PLSCOPE_SETTINGS). |
The following SQL*Plus script uses the predefined inquiry directives $$PLSQL_LINE and $$PLSQL_UNIT as ordinary PLS_INTEGER and VARCHAR2 literals, respectively, to show how their values are assigned.
SQL> SQL> CREATE OR REPLACE PROCEDURE p 2 IS-- w w w . ja v a 2s . c o m 3 i PLS_INTEGER; 4 BEGIN 5 DBMS_OUTPUT.PUT_LINE('Inside p'); 6 i := $$PLSQL_LINE; 7 DBMS_OUTPUT.PUT_LINE('i = ' || i); 8 DBMS_OUTPUT.PUT_LINE('$$PLSQL_LINE = ' || $$PLSQL_LINE); 9 DBMS_OUTPUT.PUT_LINE('$$PLSQL_UNIT = ' || $$PLSQL_UNIT); 10 END; 11 / Procedure created. SQL> SQL> SQL> BEGIN 2 p; 3 DBMS_OUTPUT.PUT_LINE('Outside p'); 4 DBMS_OUTPUT.PUT_LINE('$$PLSQL_UNIT = ' || $$PLSQL_UNIT); 5 END; 6 / Inside p i = 6 $$PLSQL_LINE = 8 $$PLSQL_UNIT = P Outside p $$PLSQL_UNIT = PL/SQL procedure successfully completed. SQL> SQL>