Architecture of PL/SQL
Basic understanding of the PL/SQL architecture is beneficial to PL/SQL programmers.
Topics
PL/SQL Engine
The PL/SQL compilation and runtime system is an engine that compiles and runs PL/SQL units.
The engine can be installed in the database or in an application development tool, such as Oracle Forms.
In either environment, the PL/SQL engine accepts as input any valid PL/SQL unit. The engine runs procedural statements, but sends SQL statements to the SQL engine in the database, as shown in Figure 2-1.
Typically, the database processes PL/SQL units.
When an application development tool processes PL/SQL units, it passes them to its local PL/SQL engine. If a PL/SQL unit contains no SQL statements, the local engine processes the entire PL/SQL unit. This is useful if the application development tool can benefit from conditional and iterative control.
For example, Oracle Forms applications frequently use SQL statements to test the values of field entries and do simple computations. By using PL/SQL instead of SQL, these applications can avoid calls to the database.
PL/SQL Units and Compilation Parameters
PL/SQL units are affected by PL/SQL compilation parameters (a category of database initialization parameters). Different PL/SQL units—for example, a package specification and its body—can have different compilation parameter settings.
A PL/SQL unit is one of these:
-
PL/SQL anonymous block
-
FUNCTION
-
LIBRARY
-
PACKAGE
-
PACKAGE
BODY
-
PROCEDURE
-
TRIGGER
-
TYPE
-
TYPE
BODY
Table 2-2 summarizes the PL/SQL compilation parameters. To display the values of these parameters for specified or all PL/SQL units, query the static data dictionary view ALL_PLSQL_OBJECT_SETTINGS
. For information about this view, see Oracle Database Reference.
Table 2-2 PL/SQL Compilation Parameters
Parameter | Description |
---|---|
Controls the compile-time collection, cross-reference, and storage of PL/SQL source text identifier data. Used by the PL/Scope tool (see Oracle Database Development Guide). For more information about |
|
Lets you control conditional compilation of each PL/SQL unit independently. For more information about |
|
Specifies the compilation mode for PL/SQL units— If the optimization level (set by
For more information about |
|
Specifies the optimization level at which to compile PL/SQL units (the higher the level, the more optimizations the compiler tries to make).
For more information about |
|
Enables or disables the reporting of warning messages by the PL/SQL compiler, and specifies which warning messages to show as errors. For more information about |
|
Lets you create For more information about byte and character length semantics, see "CHAR and VARCHAR2 Variables". For more information about |
|
Specifies whether the 12.1 PL/SQL compiler can use wrapped packages that were compiled with the 9.2 PL/SQL compiler. The default value is For more information about wrapped packages, see PL/SQL Source Text Wrapping. For more information about |
Note:
The compilation parameter PLSQL_DEBUG
, which specifies whether to compile PL/SQL units for debugging, is deprecated. To compile PL/SQL units for debugging, specify PLSQL_OPTIMIZE_LEVEL=1
.
The compile-time values of the parameters in Table 2-2 are stored with the metadata of each stored PL/SQL unit, which means that you can reuse those values when you explicitly recompile the unit. (A stored PL/SQL unit is created with one of the "CREATE [ OR REPLACE ] Statements". An anonymous block is not a stored PL/SQL unit.)
To explicitly recompile a stored PL/SQL unit and reuse its parameter values, you must use an ALTER
statement with both the COMPILE
clause and the REUSE
SETTINGS
clause. All ALTER
statements have this clause. For a list of ALTER
statements, see "ALTER Statements".