Oracle
  Home arrow Oracle arrow Page 4 - Conditional Compilation for Oracle Database 10g
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ORACLE

Conditional Compilation for Oracle Database 10g
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    2007-11-15


    Table of Contents:
  • Conditional Compilation for Oracle Database 10g
  • Examples of Conditional Compilation
  • The Inquiry Directive
  • Setting compilation environment parameters

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Conditional Compilation for Oracle Database 10g - Setting compilation environment parameters
    ( Page 4 of 4 )

    The following information (corresponding to the values in the USER_PLSQL_OBJECT_SETTINGS data dictionary view) is available via inquiry directives:

    $$PLSQL_DEBUG
      
    Debug setting for this compilation unit

    $$PLSQL_OPTIMIZE_LEVEL
       Optimization level for this compilation unit

    $$PLSQL_CODE_TYPE
      
    Compilation mode for the unit

    $$PLSQL_WARNINGS
      
    Compilation warnings setting for this compilation unit

    $$NLS_LENGTH_SEMANTICS
       Value set for the NLS length semantics

    See the cc_plsql_parameters.sql file on the book’s web site for a demonstration that uses each of these parameters.

    Referencing unit name and line number

    Oracle implicitly defines two very useful inquiry directives for use in $IF and $ERROR directives:

    $$PLSQL_UNIT
      
    Name of the compilation unit in which the reference
       appears

    $$PLSQL_LINE
      
    Line number of the compilation unit where the
       reference appears

    You can call DBMS_UTILITY.FORMAT_CALL_STACK and DBMS_UTILITY. FORMAT_ERROR_BACKTRACE to obtain current line numbers, but then you must also parse those strings to find the line number and program unit name. These inquiry directives provide the information more directly. Here is an example:

      BEGIN
        
    IF l_balance < 10000
        
    THEN
           
    raise_error (
              
    err_name => 'BALANCE TOO LOW'
             
    ,failed_in => $$plsql_unit
             
    ,failed_on => $$plsql_line
           
    );
       
    END IF;
       
    ...
      END;

    Run cc_line_unit.sql to see a demonstration of using these last two directives.

    Note that when $$PLSQL_UNIT is referenced inside a package, it will return the name of the package, not the individual procedure or function within the package.

    Using the PLSQL_CCFLAGS parameter

    Oracle offers a new initialization parameter, PLSQL_CCFLAGS, that you can use with conditional compilation. Essentially, it allows you to define name-value pairs, and the name can then be referenced as an inquiry directive in your conditional compilation logic. Here is an example:

      ALTER SESSION SET PLSQL_CCFLAGS = 'use_debug:TRUE, trace_level:10';

    The flag name can be set to any valid PL/SQL identifier, including reserved words and keywords (the identifier will be prefixed with $$, so there will be no confusion with normal PL/SQL code). The value assigned to the name must be one of the following: TRUE, FALSE, NULL, or a PLS_INTEGER literal.

    The PLSQL_CCFLAGS value will be associated with each program that is then compiled in that session. If you want to keep those settings with the program, then future compilations with the ALTER...COMPILE command should include the REUSE SETTINGS clause.

    Because you can change the value of this parameter and then compile selected program units, you can easily define different sets of inquiry directives for different programs.

    Note that you can refer to a flag that is not defined in PLSQL_CCFLAGS; this flag will evaluate to NULL. If you enable compile-time warnings, this reference to an undefined flag will cause Oracle to report a PLW-06003: unknown inquiry directive warning (unless the source code is wrapped).

    Please check back next week for the continuation of this article.



     
     
    >>> More Oracle Articles          >>> More By O'Reilly Media
     

       

    ORACLE ARTICLES

    - Oracle's Turn to Play in the Sun
    - Implementing and Using Oracle`s Restore Poin...
    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek