SunQuest
 
       Oracle
  Home arrow Oracle arrow Page 4 - Tuning PL/SQL Code
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
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? 
ORACLE

Tuning PL/SQL Code
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2007-12-20

    Table of Contents:
  • Tuning PL/SQL Code
  • Optimizing PL/SQL Performance
  • Protecting Stored Code
  • Dynamic Wrapping with DBMS_DDL
  • Guidelines for Working with Wrapped Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Tuning PL/SQL Code - Dynamic Wrapping with DBMS_DDL


    (Page 4 of 5 )

    Oracle Database 10g Release 2 provides a way to wrap code that is generated dynamically: the WRAP and CREATE_WRAPPED programs of the DBMS_DDL package:

    DBMS_DDL.WRAP
      
    Returns a string containing an obfuscated version of
       your code

    DBMS_DDL.CREATE_WRAPPED
      
    Compiles an obfuscated version of your code into the
       database

    Both programs are overloaded to work with a single string and with arrays of strings based on the DBMS_SQL.VARCHAR2A and DBMS_SQL.VARCHAR2S collection types. Here are two examples that use these programs:

    • Obfuscate and display a string that creates a tiny procedure:

        SQL> DECLARE
          2    
      l_program   VARCHAR2 (32767);
          3  
      BEGIN
          4    
      l_program := 'CREATE OR REPLACE PROCEDURE dont_look IS BEGIN NULL; END;';
          5    
      DBMS_OUTPUT.put_line (SYS.DBMS_DDL.wrap (l_program));
          6 
      END;
          7 /
        CREATE OR REPLACE PROCEDURE dont_look wrapped

       
      a000000
        369
        abcd
        ....  
        XtQ19EnOI8a6hBSJmk2NebMgPHswg5nnm7+ fMr2ywFy4CP6Z9P4I/v4rpXQruMAy/tJepZmB 
        CC0r
        uIHHLcmmpkOCnm4=
       
    • Read a PL/SQL program definition from a file, obfuscate it, and compile it into the database:

        /* File on web: obfuscate_from_file.sql */
        CEATE OR REPLACE PROCEDURE obfuscate_from_file (
          dir_in   IN   VARCHAR2
       
      , file_in  IN   VARCHAR2
        )
        IS
          
      l_file   UTL_FILE.file_type;
           l_lines  DBMS_SQL.varchar2s;

          
      PROCEDURE read_file (lines_out IN OUT NOCOPY DBMS_SQL.varchar2s)
           IS BEGIN ... not critical to the example ... END read_file;
        BEGIN
           read_file (l_lines);
           SYS.DBMS_DDL.create_wrapped (l_lines, l_lines.FIRST, l_lines.LAST);

        END obfuscate_from_file;

    More Oracle Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Oracle PL/SQL Programming, Fourth...
     

    Buy this book now. This article is excerpted from chapter 20 of the book Oracle PL/SQL Programming, Fourth Edition, written by Steven Feuerstein and Bill Pribyl (O'Reilly; ISBN: 0596009771). Check it out today at your favorite bookstore. Buy this book now.

       

    ORACLE ARTICLES

    - 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...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway