Conditional compilation eliminates sections from the compiled code entirely. If you flipped the debug_flag to TRUE, you 'd still be printing Debug=F until you recompiled your source code. ________________________________ From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Ethan Post Sent: Tuesday, May 15, 2007 11:33 AM To: oracle-l Subject: Condition Compilation Question I am reading the section regarding conditional compilation here. http://www.oracle.com/technology/pub/articles/10gdba/nanda_10gr2dba_part 1.html#compile What is the difference for the example below and using a standard "if then else"? Why would below be better? Isn't it evaluated every time? ------------------------------------------------------------------------ ------------------------------------------------------------ Let's examine another variation of this new feature. In addition to the definition of a conditional variable, you can also check a static constant of a package in the conditional compilation. For example, suppose you want to control the debugging output of a PL/SQL procedure based on a Boolean packaged constant. First you create the package as create or replace package debug_pkg is debug_flag constant boolean := FALSE; end; The debug_flag is the constant that determines the conditional logic in the code. You can now embed the code inside the package as follows: create or replace procedure myproc as begin $if debug_pkg.debug_flag $then dbms_output.put_line ('Debug=T'); $else dbms_output.put_line ('Debug=F'); $end end; Note that the packaged constant is referenced directly without any $ sign. In this case, there is no need to set any session- or system-level conditional compilation parameters. While the function is compiled, you do not need to pass any additional clause either. To see how this works, execute: SQL> exec myproc Debug=F Because the value of debug_pkg.debug_flag is FALSE now, the execution of the procedure returned "F" as expected. Now, change the constant value: create or replace package debug_pkg is debug_flag constant boolean := TRUE; end; Then, execute the procedure again: SQL> exec myproc Debug=T The procedure picked up the value of the constant to show "T," as expected. Note a very important difference here-you did not need to recompile the procedure; the change to the constant was picked up automatically! >>> This e-mail and any attachments are confidential, may contain legal, professional or other privileged information, and are intended solely for the addressee. If you are not the intended recipient, do not use the information in this e-mail in any way, delete this e-mail and notify the sender. CEG-IP2