You reference these non-PL/SQL expressions using the inquiry directive, or $$. That is, you preface a ccflag or a PL/SQL Compiler initialization parameter with $$. This signals the conditional compilation engine to reads its value in at compile-time, for example:
$IF $$PLSQL_LINE=15 $THEN
debug('That was line 15');
$END ;
You set user-defined ccflags by assigning a string of name-value pairs to the Oracle parameter PLSQL_CCFLAGS in the format 'name:value[,name:value][,name:value]....'. For example, to set the values of ccflags named "set_debug_on", "use_10g_features", and "compile_w_extras", you would set PLSQL_CCFLAGS as follows:
PLSQL_CCFLAGS = 'set_debug_on:true,use_10g_features:false,compile_w_extras:false' ;
You can set PLSQL_CCFLAGS at the session or system level with ALTER SESSION or ALTER SYSTEM, respectively. Or, you can set PLSQL_CCFLAGS at compile time, for individual package or procedure compilation.
Here's an example of setting user-defined ccflags at compile time:
SQL> alter package PAYROLL_CALC compile
2> plsql_ccflags =
3> 'no_commit_trans:true,print_debug_msg:true'
4> reuse settings ;
Here's an example of setting the value of PLSQL_CCFLAGS at the ALTER SESSION level:
SQL> alter session set PLSQL_CCFLAGS =
2> 'set_debug_on:true' ;
And here's an example of setting the value of PLSQL_CCFLAGS at compile-time:
SQL> alter system set PLSQL_CCFLAGS =
2> 'use_10g_features:false' ;
You can combine package constants with ccflags in the conditional compilation IF-test, for example:
$IF $$DEBUG_ON or PayrollConstants.c_Debug $THEN
debug('Error');
$END
You can set the package constant to TRUE during development and FALSE thereafter. After development, you can recompile the package with the ccflag DEBUG_ON set to TRUE whenever it's necessary for debugging. The following case study looks at this concept in more detail.