Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Condition Compilation Question

RE: Condition Compilation Question

From: Bobak, Mark <Mark.Bobak_at_il.proquest.com>
Date: Tue, 15 May 2007 13:58:43 -0400
Message-ID: <AA29A27627F842409E1D18FB19CDCF270C3BF4F4@AABO-EXCHANGE02.bos.il.pqe>


Yes, but I think you're missing a subtlety, though I agree the writer could have been more clear on the point!  

"you did not need to recompile the procedure" (emphasis on "you" here!). The procedure did in fact get recompiled, cause it has a dependency on the package!  

Here's my test case:
create or replace package debug_pkg
is

   debug_flag constant boolean := FALSE; end;
/

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;
/

select status from dba_objects where owner=user and object_name = 'MYPROC'
/

exec myproc
create or replace package debug_pkg
is

   debug_flag constant boolean := TRUE;
end;
/

select status from dba_objects where owner=user and object_name = 'MYPROC'
/

exec myproc
select status from dba_objects where owner=user and object_name = 'MYPROC'
/

And here's the output you'll see when you run it:    

pbcdb1_(elibpep)$sqlplus mbobak  

SQL*Plus: Release 10.2.0.3.0 - Production on Tue May 15 13:57:31 2007  

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.  

Enter password:  

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options  

SQL> @my_test_case  

Package created.  

Procedure created.  

STATUS



VALID   PL/SQL procedure successfully completed.  

Package created.  

STATUS



INVALID   PL/SQL procedure successfully completed.  

STATUS



VALID You can clearly see the procedure goes from invalid to valid via an implicit recompile, on execute of the procedure.  

-Mark

-- 
Mark J. Bobak 
Senior Oracle Architect 
ProQuest/CSA 

"There are 10 types of people in the world:  Those who understand
binary, and those who don't." 

 


________________________________

From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Ethan Post
Sent: Tuesday, May 15, 2007 12:54 PM
To: Brady, Mark
Cc: oracle-l
Subject: Re: Condition Compilation Question


Quoted from the article.

"Note a very important difference here-you did not need to recompile the
procedure;"

There are two examples in the article one in which you do have to
recompile and one in which you don't. Assuming the example works as
stated and thinking about this some more I am inclined to think that the
"$if $else" code only executes when the package is loaded into memory
for a given session. If the flag is changed in the other package then
the other package is invalidated and must be revalidated again. I might
have to create a couple test cases. 

- Ethan


On 5/15/07, Brady, Mark <Mark.Brady_at_constellation.com> wrote: 

	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. 

	 

	 

	 



--
http://www.freelists.org/webpage/oracle-l
Received on Tue May 15 2007 - 12:58:43 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US