PL/SQLThis is a featured page

This is a preliminary page mostly consisting of the outline. I will be filling this out in pieces over the next day or so. If you have anything you'd like to add or change, feel free.

PL/SQL, the Procedural Language for SQL, was first introduced with Oracle SQL*Forms 3.0. Subsequently, after having been released in 1991 as the Procedural Option for Oracle 6, PL/SQL has become one of Oracle's premier development languages.

Background


Since its inception, PL/SQL has been based on the high-level Ada programming language. Accordingly, most of PL/SQL's useful features such as packages, types, functions, and procedures, are all derived from Ada.

Preprocessing


In that it supports conditional compilation and basic definitions, Oracle 10g PL/SQL Conditional Compilation resembles a source language preprocessor. However, unlike a traditional preprocessor, PL/SQL preprocessing is not performed as the first step of the compilation process nor is it performed by a specialized preprocessing component. In fact, the selection directive (similar to the C #ifdef) it is actually built into the PL/SQL compiler and is able to reuse much of the compiler's standard boolean logic.

Basic definitions (similar to the C #define) are called inquiry directives, and are also supported. It is important to note that, unlike other languages, the inquiry directive cannot be used to define macros.

Compilation


Before PL/SQL can be used, it must be compiled into PL/SQL virtual machine executable code (m-code), C code (which must also be compiled and linked), or native machine code (11g only). Like a traditional compiler, the PL/SQL compiler consists of several modules specialized to handle certain phases of the compilation process:

The Compiler Front-End


The PL/SQL compiler front-end is responsible for parsing PL/SQL compilation units and performing semantic and syntactic validation of them. Similarly, the front-end translates the compilation unit into an intermediate representation called Descriptive Intermediate Attributed Notation for Ada (DIANA); this intermediate representation is understood by the back-end.

The Compiler Back-End


After DIANA has been generated, the back-end performs optimization and code generation from DIANA into either m-code, C-language calls to the PVM, or native code linked as shared libraries.

Within recent years, the PL/SQL compiler has been improved to support compile-time optimization and standard compiler features such as inlining.

Execution


PL/SQL execution can take two forms, native and interpreted. The default and most common method employed by users is interpreted mode. In interpreted mode, the DIANA is compiled into m-code, a proprietary byte code, and executed in the PL/SQL virtual machine (PVM).

On the other hand, native mode compilation consists of a code generator which is able to transform DIANA into C (prior to 11g), or assembling and linking it directly. Native code execution calls the same instructions as m-code, but generally has less overhead and is usually faster.

Debugging


PL/SQL debugging can be accomplished using the DBMS_DEBUG package. This same package is used by all the graphical PL/SQL debuggers.

Wrapping


In order to hide proprietary algorithms and prevent users from modifying commercial PL/SQL programs, Oracle has provided a utility called wrap. The sole purpose of the wrap utility is to perform obfuscation of PL/SQL, thereby making it difficult for people to understand.

Prior to Oracle Database 10.2, the wrap utility stripped out comments and translated compilation units into DIANA, which it then wrote back out into the file as plain text. Certain components of plain-text DIANA contained a readable symbol table which made it somewhat easy to decipher.

As of 10.2, the wrap utility strips out comments and compresses the original PL/SQL. Then, wrap checksums the compressed code and stores it in a buffer. After this step, wrap performs basic character substitution and appends the substituted compressed code to the checksum buffer. Once this is complete, the entire buffer is base-64 encoded and written out to the file.

Contrary to old Oracle documentation, it has always been possible to un-wrap wrapped PL/SQL. While components of the former, pre-10g method could be read, whether it was more secure than the new method is debatable.

Best Practices



Links





No user avatar
jhartelt
Latest page update: made by jhartelt , Jun 24 2008, 1:09 PM EDT (about this update About This Update jhartelt removed a typo - jhartelt

2 words added
1 word deleted

view changes

- complete history)
Keyword tags: PL/SQL PL/SQL Intro
More Info: links to this page
Started By Thread Subject Replies Last Post
smit_sign Duplicate names of datafiles 6 Jun 29 2009, 5:51 AM EDT by samrat.wani
Thread started: Feb 14 2009, 9:47 AM EST  Watch
Can some one please provide the script to check the duplicate datafiles in database.

Thanks
Smit
Do you find this valuable?    
Show Last Reply
jcgeorge PL-SQL Context package Information 0 Oct 4 2008, 8:59 AM EDT by jcgeorge
Thread started: Oct 4 2008, 8:59 AM EDT  Watch
Hi ,

I have an application wherein I have a flow with PL-SQLs package are called within other

eg : PACKAGE1.PROCEDURE1 Calls PACKAGE2.PROCEDURE2 Calls PACKAGE3.PROCEDURE3

Since the number of packages and calling hierarchy is large , is there any way that I can get the current context package and procedure without using any custom registry?

Thanks

Joseph
Do you find this valuable?    
Keyword tags: None
sabraha5 Base64 Encoding/Decoding from PL/SQL 5 Jul 28 2008, 6:33 AM EDT by sabraha5
Thread started: Jul 16 2008, 11:21 AM EDT  Watch
Does anyone know of a way to do Base64 encoding/decoding from within PL/SQL? Thank you for your help!
4  out of 5 found this valuable. Do you?    
Keyword tags: Base64 PL/SQL PL/SQL Intro
Show Last Reply
Showing 3 of 5 threads for this page - view all

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)