Search notes:

Oracle: DBA_PLSQL_OBJECT_SETTINGS

dba_plsql_object_settings shows compiler settings that were in force when a PL/SQL object (stored procedure, function, package etc.) was compiled.
Such settings include, for example those that relate to conditional compilation.
dba_plsql_object_settings comes in all four variants: user_plsql_object_settings, all_plsql_object_settings, dba_plsql_object_settings and cdb_plsql_object_settings.

Columns

The columns owner, name and type uniqly identify the PL/SQL object for which information is shown.
Column name Value of what at compilation time
plsql_optimize_level
plsql_code_type
plsql_debug
plsql_warnings Init parameter plsql_warnings.
nls_length_semantics Init parameter nls_length_semantics
plsql_ccflags Init parameter plsql_ccflags
plscope_settings Init parameter plscope_settings:

Select settings of a given object

select
   plsql_optimize_level,
   plsql_code_type,
   plsql_debug,
   plsql_warnings,
   plsql_ccflags,
   plscope_settings,
   nls_length_semantics,
   origin_con_id
from
   dba_plsql_object_settings
where
   owner =  user           and
   name  = 'XYZ'           and
   type  = 'PACKAGE BODY';

Example 1

create or replace package tq84_pck as -- {

  procedure p;

end tq84_pck; -- }
/

create or replace package body tq84_pck as -- {

  procedure p is -- {
  begin

    $IF $$TQ84_BOOL $THEN
        dbms_output.put_line('hello, world. The num is: '   || $$TQ84_NUM);
    $ELSE
        dbms_output.put_line('good bye, world. The num is ' || $$TQ84_NUM);
    $END

  end p; -- }

end tq84_pck; -- }
/

exec tq84_pck.p
-- good bye, world. The num is

column plsql_code_type        format a15
column plsql_debug            format a15
column plsql_warnings         format a15
column nls_length_semantics   format a15
column plsql_ccflags          format a25
column plscope_settings       format a16

select
  plsql_optimize_level,
  plsql_code_type,
  plsql_debug,
  plsql_warnings,
  nls_length_semantics,
  plsql_ccflags,
  plscope_settings
from
  user_plsql_object_settings
where
  type = 'PACKAGE BODY' and
  name = 'TQ84_PCK';
--
-- PLSQL_OPTIMIZE_LEVEL PLSQL_CODE_TYPE PLSQL_DEBUG     PLSQL_WARNINGS  NLS_LENGTH_SEMA PLSQL_CCFLAGS             PLSCOPE_SETTINGS
-- -------------------- --------------- --------------- --------------- --------------- ------------------------- ----------------
--                    2 INTERPRETED     FALSE           DISABLE:ALL     CHAR                                      IDENTIFIERS:NONE



alter session set plsql_ccflags='TQ84_BOOL:TRUE';
select substrb(value, 1, 50) val from v$parameter where name = 'plsql_ccflags';
-- VAL
-- --------------------------------------------------
-- TQ84_BOOL:TRUE

select
  plsql_optimize_level,
  plsql_code_type,
  plsql_debug,
  plsql_warnings,
  nls_length_semantics,
  plsql_ccflags,
  plscope_settings
from
  user_plsql_object_settings
where
  type = 'PACKAGE BODY' and
  name = 'TQ84_PCK';
--
-- PLSQL_OPTIMIZE_LEVEL PLSQL_CODE_TYPE PLSQL_DEBUG     PLSQL_WARNINGS  NLS_LENGTH_SEMA PLSQL_CCFLAGS             PLSCOPE_SETTINGS
-- -------------------- --------------- --------------- --------------- --------------- ------------------------- ----------------
--                    2 INTERPRETED     FALSE           DISABLE:ALL     CHAR                                      IDENTIFIERS:NONE

alter package tq84_pck compile;

select
  plsql_optimize_level,
  plsql_code_type,
  plsql_debug,
  plsql_warnings,
  nls_length_semantics,
  plsql_ccflags,
  plscope_settings
from
  user_plsql_object_settings
where
  type = 'PACKAGE BODY' and
  name = 'TQ84_PCK';
--
-- PLSQL_OPTIMIZE_LEVEL PLSQL_CODE_TYPE PLSQL_DEBUG     PLSQL_WARNINGS  NLS_LENGTH_SEMA PLSQL_CCFLAGS             PLSCOPE_SETTINGS
-- -------------------- --------------- --------------- --------------- --------------- ------------------------- ----------------
--                    2 INTERPRETED     FALSE           DISABLE:ALL     CHAR            TQ84_BOOL:TRUE            IDENTIFIERS:NONE


exec tq84_pck.p
-- hello, world. The num is:

alter session set plsql_ccflags='TQ84_NUM:42';
alter package tq84_pck compile;
exec tq84_pck.p
-- good bye, world. The num is 42

drop package tq84_pck;
Github repository Oracle-Patterns, path: /Installed/data-dictionary/plsql_object_settings/example-01.sql

See also

Oracle PL/SQL: Errors and warnings

Index