Oracle Inquiry Directives and Compilation Parameters
Version 21c

General Information
Library Note Morgan's Library Page Header
Which has the higher priority in your organization: Deploying a new database or securing the ones you already have? Looking for a website, and resources, dedicated solely to securing Oracle databases? Check out DBSecWorx.
Purpose Predefined Inquiry Directives act like built-in functions, but are not objects such as can be found in DBA_OBJECTS that return values related to compiled PL/SQL objects. The Inquiry Directives are of great value in creating robust debugging and error handling routines.

Some of the code samples on this page relate to PL/SCOPE ... click on the link at the bottom of this page to view additional information and code examples with PL/SCOPE.
 
Predefined Inquiry Directives
$$PLSQL_LINE set serveroutput on

BEGIN
  NULL;
  NULL;
  NULL;
  dbms_output.put_line($$plsql_line);
END;
/
$$PLSQL_UNIT CREATE OR REPLACE PROCEDURE test AUTHID DEFINER IS
BEGIN
  dbms_output.put_line('I am ' || $$plsql_unit);
END test;
/

set serveroutput on

exec test
$$PLSQL_UNIT_OWNER CREATE OR REPLACE PROCEDURE test AUTHID DEFINER IS
BEGIN
  dbms_output.put_line('I am owned by ' || $$plsql_unit_owner);
END test;
/

set serveroutput on

exec test
$$PLSQL_UNIT_TYPE CREATE OR REPLACE PROCEDURE test AUTHID DEFINER IS
BEGIN
  dbms_output.put_line('I am a ' || $$plsql_unit_type);
END test;
/

set serveroutput on

exec test
 
Assigning Values to Inquiry Directives
Demo ALTER SESSION SET PLSQL_CCFlags = 'UW_Flag:1, Some_Flag:2, PLSQL_CCFlags:42';

set serveroutput on

BEGIN
  dbms_output.put_line($$UW_Flag);
  dbms_output.put_line($$Some_Flag);
  dbms_output.put_line($$PLSQL_CCFlags);
END;
/
 
Compilation Parameters
Demo CREATE OR REPLACE PROCEDURE test AUTHID DEFINER IS
BEGIN
  dbms_output.put_line('$$PLSCOPE_SETTINGS = ' || $$PLSCOPE_SETTINGS);
  dbms_output.put_line('$$PLSQL_CCFLAGS = ' || $$PLSQL_CCFLAGS);
  dbms_output.put_line('$$PLSQL_CODE_TYPE = ' || $$PLSQL_CODE_TYPE);
  dbms_output.put_line('$$PLSQL_OPTIMIZE_LEVEL = ' || $$PLSQL_OPTIMIZE_LEVEL);
  dbms_output.put_line('$$PLSQL_WARNINGS = ' || $$PLSQL_WARNINGS);
  dbms_output.put_line('$$NLS_LENGTH_SEMANTICS = ' || $$NLS_LENGTH_SEMANTICS);
END test;
/

set serveroutput on

exec test

Related Topics
Built-in Functions
Built-in Packages
DBMS_APPLICATION_INFO
DBMS_DB_VERSION
Pipelined Table Functions
PL/SCOPE
Procedures
Table Triggers
Types
What's New In 19c
What's New In 20c-21c

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2019 Daniel A. Morgan All Rights Reserved
  DBSecWorx