Oracle Inquiry Directives and Compilation Parameters
Version 12.2.0.1

General Information
Library Note Morgan's Library Page Header
The Library is currently in the process of being upgraded from Oracle Database Version 12.1.0.2 to 12.2.0.1. Demos are being upgraded to reflect the new Container paradigm as well as EBR (Edition Based Redefinition) and may contain references to CDBs, PDBs, and other objects you may not be familiar with such as CDB_OBJECTS_AE: Welcome to 12c.

Do you remember when mainframes were replaced by client-server? When client-server was replaced by n-tier architecture? The "Cloud" is a distraction ... DevOps is not. Prepare for the future.
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);
  -- (new in 12.2)
  dbms_output.put_line('$$PERMIT_92_WRAP_FORMAT = ' || $$PERMIT_92_WRAP_FORMAT);
END test;
/

set serveroutput on

exec test

Related Topics
DBMS_APPLICATION_INFO
DBMS_DB_VERSION
Functions
Packages
Pipelined Table Functions
PL/SCOPE
Procedures
Table Triggers
Types
What's New In 12cR1
What's New In 12cR2

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-2017 Daniel A. Morgan All Rights Reserved