Oracle® Database PL/SQL User's Guide and Reference 10g Release 2 (10.2) Part Number B14261-01 |
|
|
View PDF |
This section describes new features of PL/SQL release 10g, and provides pointers to additional information.
The following sections describe the new features in PL/SQL:
New Features in PL/SQL for Oracle Database 10g Release 2 (10.2)
New Features in PL/SQL for Oracle Database 10g Release 1 (10.1)
See Also:
Information and examples related to new PL/SQL features on the PL/SQL home page on Oracle Technology Network (OTN):
Oracle By Example - Using Oracle Database 10g PL/SQL New Features on the Oracle Technology Network (OTN, including bulk binding enhancements and debugging PL/SQL with JDeveloper:
http://www.oracle.com/technology/obe/obe10gdb/develop/plsql/plsql.htm
These are the new features for Oracle Database 10g Release 2 (10.2).
This feature enables you to selectively include code depending on the values of the conditions evaluated during compilation. For example, conditional compilation enables you to determine which PL/SQL features in a PL/SQL application are used for specific database releases. The latest PL/SQL features in an application can be run on a new database release while at the same time those features can be conditionalized so that the same application is compatible with a previous database release. Conditional compilation is also useful when you want to execute debugging procedures in a development environment, but want to turn off the debugging routines in a production environment. See "Conditional Compilation".
DBMS_DDL
wrap subprograms obfuscate (hide) dynamically generated PL/SQL code units in an Oracle database so that implementation details are hidden from users. See Appendix A, "Obfuscating PL/SQL Source Code".
The range of the PLS_INTEGER
datatype is -2147483648 to 2147483647, represented in 32 bits. See "PLS_INTEGER Datatype".
These are the new features for Oracle Database 10g Release 1 (10.1).
PL/SQL performance is improved across the board. Most improvements are automatic, with no action required from you. Global optimization of PL/SQL code is controlled by the PLSQL_OPTIMIZE_LEVEL
initialization parameter. The default optimization level improves performance for a broad range of PL/SQL operations. Most users should never need to change the default optimization level.
Performance improvements include better integer performance, reuse of expression values, simplification of branching code, better performance for some library calls, and elimination of unreachable code.
The new datatypes BINARY_FLOAT
and BINARY_DOUBLE
can improve performance in number-crunching applications, such as processing scientific data.
Native compilation is easier and more integrated, with fewer initialization parameters to set, less compiler configuration, the object code is stored in the database, and compatibility with Oracle Real Application Clusters environments.
The FORALL
statement can handle associative arrays and nested tables with deleted elements. You can now use this performance construct in more situations than before, and avoid the need to copy elements from one collection to another.
The configuration of initialization parameters and the command setup for native compilation has been simplified. The only required parameter is PLSQL_NATIVE_LIBRARY_DIR
. The parameters related to the compiler, linker, and make utility have been obsoleted. Native compilation is turned on and off by a separate initialization parameter, PLSQL_CODE_TYPE
, rather than being one of several options in the PLSQL_COMPILER_FLAGS
parameter, which is now deprecated.
The $ORACLE_HOME/plsql/spnc_commands
file contains the commands and options for compiling and linking, rather than a makefile. The spnc_commands
file. A new script, dbmsupgnv.sql
, has been provided to recompile all the PL/SQL modules in a database as NATIVE
. The dbmsupgin.sql
script recompiles all the PL/SQL modules in a database as INTERPRETED
.
A package body and its specification do not need to be compiled with the same setting for native compilation. For example, a package body can be compiled natively while the package specification is compiled interpreted, or vice versa.
Natively compiled subprograms are stored in the database, and the corresponding shared libraries are extracted automatically as needed. You do not need to worry about backing up the shared libraries, cleaning up old shared libraries, or what happens if a shared library is deleted accidentally.
Any errors that occur during native compilation are reflected in the USER_ERRORS
dictionary view and by the SQL*Plus command SHOW ERRORS
.
See "Compiling PL/SQL Code for Native Execution".
You can use the INDICES OF
and VALUES OF
clauses with the FORALL
statement to iterate over non-consecutive index values. For example, you can delete elements from a nested table, and still use that nested table in a FORALL
statement. See "Using the FORALL Statement".
New datatypes BINARY_FLOAT
and BINARY_DOUBLE
represent floating-point numbers in IEEE 754 format. These types are useful for scientific computation where you exchange data with other programs and languages that use the IEEE 754 standard for floating-point. Because many computer systems support IEEE 754 floating-point operations through native processor instructions, these types are efficient for intensive computations involving floating-point data.
Support for these types includes numeric literals such as 1.0f
and 3.141d
, arithmetic operations including square root and remainder, exception handling, and special values such as not-a-number (NaN) and infinity.
The rules for overloading subprograms are enhanced, so that you can write math libraries with different versions of the same function operating on PLS_INTEGER
, NUMBER
, BINARY_FLOAT
, and BINARY_DOUBLE
parameters. See "PL/SQL Number Types".
Staring with Oracle 10g release 1, the BINARY_INTEGER
datatype was changed to be identical to PLS_INTEGER
so the datatypes can be used interchangeably. See "BINARY_INTEGER Datatype".
Note:
Prior to Oracle 10g release 1,PLS_INTEGER
was more efficient than BINARY_INTEGER
, so you might prefer to use the PLS_INTEGER
datatype if your code will be run under older database releases. However, the PLS_INTEGER
datatype has a different overflow behavior than the BINARY_INTEGER
datatype in releases prior to Oracle 10g release 1. Prior to Oracle 10g release 1, when a calculation with two BINARY_INTEGER
datatypes overflowed the magnitude range of BINARY_INTEGER
, the result was assigned to a NUMBER
datatype and no overflow exception was raised. See "PLS_INTEGER Datatype".You can now overload subprograms that accept different kinds of numeric arguments, to write math libraries with specialized versions of each subprogram for different datatypes. See "Guidelines for Overloading with Numeric Types".
Nested tables defined in PL/SQL have many more operations than previously. You can compare nested tables for equality, test whether an element is a member of a nested table, test whether one nested table is a subset of another, perform set operations such as union and intersection, and much more. See "Assigning Collections" and "Comparing Collections".
Oracle can issue warnings when you compile subprograms that produce ambiguous results or use inefficient constructs. You can selectively enable and disable these warnings through the PLSQL_WARNINGS
initialization parameter and the DBMS_WARNING
package. See "Overview of PL/SQL Compile-Time Warnings".
Instead of doubling each single quote inside a string literal, you can specify your own delimiter character for the literal, and then use single quotes inside the string. See "String Literals".
You can implicitly convert from CLOB
to NCLOB
or from NCLOB
to CLOB
. Because this can be an expensive operation, it might help maintainability to continue using the TO_CLOB
and TO_NCLOB
functions.
If you are familiar with UNIX-style regular expressions, you can use them while performing queries and string manipulations. You use the REGEXP_LIKE
operator in SQL queries, and the REGEXP_INSTR
, REGEXP_REPLACE
, and REGEXP_SUBSTR
functions anywhere you would use INSTR
, REPLACE
, and SUBSTR
. See "Summary of PL/SQL Built-In Functions" and "Do Not Duplicate Built-in String Functions".
The functions SCN_TO_TIMESTAMP
and TIMESTAMP_TO_SCN
let you translate between a date and time, and the system change number that represents the database state at a point in time. See Example 3-2, "Using the SCN_TO_TIMESTAMP and TIMESTAMP_TO_SCN Functions". See "Summary of PL/SQL Built-In Functions".