Oracle® TimesTen In-Memory Database PL/SQL Developer's Guide 11g Release 2 (11.2.2) Part Number E21639-03 |
|
|
PDF · Mobi · ePub |
TimesTen supplies public PL/SQL packages, listed immediately below, to extend database functionality and provide PL/SQL access to SQL features. TimesTen installs these packages automatically for your use. Packages that are part of the PL/SQL language itself or are otherwise for Oracle internal use only are not shown here or described in this chapter.
This chapter lists and briefly describes the subprograms that comprise each package. For details on these PL/SQL packages, refer to Oracle TimesTen In-Memory Database PL/SQL Packages Reference.
The DBMS_LOB
package provides subprograms to operate on BLOBs, CLOBs, and NCLOBs, including temporary LOBs.
Notes:
TimesTen does not support DBMS_LOB
subprograms intended specifically for BFILEs, SecureFiles (including Database File System features), or inserting or deleting data fragments in the middle of a LOB.
DBMS_LOB
procedures and functions are supported for both TimesTen LOBs and passthrough LOBs, which are LOBs in Oracle Database accessed through TimesTen and exposed as TimesTen LOBs. Note, however, that CREATETEMPORARY
can only be used to create a temporary LOB in TimesTen. If a temporary passthrough LOB is created using some other mechanism, such as SQL, ISTEMPORARY
and FREETEMPORARY
can be used on that LOB.
As with TimesTen local LOBs, a locator for a passthrough LOB does not remain valid past the end of the transaction.
In addition to copying from one TimesTen LOB to another, COPY
can copy from a TimesTen LOB to a passthrough LOB, from a passthrough LOB to a TimesTen LOB, or from one passthrough LOB to another passthrough LOB. An attempt to copy a passthrough LOB to a TimesTen LOB when the passthrough LOB is larger than the TimesTen LOB size limit will result in an error. ("COPY procedures" in Oracle TimesTen In-Memory Database PL/SQL Packages Reference provides examples for copying LOBs.)
See "Passthrough LOBs" for related information.
Table 8-1 describes the supported DBMS_LOB
subprograms.
Table 8-1 DBMS_LOB subprograms
Subprogram | Description |
---|---|
|
Appends the contents of the source LOB to the destination LOB. |
|
Closes a previously opened LOB. |
|
Compares two entire LOBs or parts of two LOBs. |
|
Reads character data from a source |
|
Takes a source |
|
Copies all or part of the source LOB to the destination LOB. |
|
Creates a temporary LOB in the temporary data partition. Any of the durations supported by Oracle Database is permitted ( |
|
Erases all or part of a LOB. |
|
Frees a temporary LOB in the temporary data partition. |
|
Returns the storage limit for the LOB type of the specified LOB. |
|
In TimesTen, this simply returns the value 32 KB for interoperability. Do not rely on this value for performance tuning. |
|
Returns the length of the LOB value, in bytes for a BLOB or characters for a CLOB or NCLOB. |
|
Returns the matching position of the nth occurrence of the pattern in the LOB. |
|
Checks to see if the LOB was already opened using the input locator. |
|
Checks whether the locator is pointing to a temporary LOB. |
|
Opens a LOB (persistent or temporary) in the indicated mode, read/write or read-only. Note: Opening a LOB is similar conceptually, but not technically, to opening a file. Opening a LOB is more like a hint regarding resources to be required. |
|
Reads data from the LOB starting at the specified offset. |
|
Returns part of the LOB value starting at the specified offset. |
|
Trims the LOB value to the specified shorter length. |
|
Writes data to the LOB from a specified offset. |
|
Writes a buffer to the end of a LOB. |
The DBMS_LOCK
package provides an interface to lock-management services. In the current release, TimesTen supports only the sleep feature.
Table 8-2 describes the supported DBMS_LOCK
subprogram.
Table 8-2 DBMS_LOCK subprograms
Subprogram | Description |
---|---|
|
This procedure suspends the session for a given duration. Specify the amount of time in seconds. The smallest supported increment is a hundredth of a second. For example: DBMS_LOCK.SLEEP(1.95); Notes:
|
The DBMS_OUTPUT
package enables you to send messages from stored procedures and packages. The package is useful for displaying PL/SQL debugging information.
Table 8-3 describes the DBMS_OUTPUT
subprograms.
Table 8-3 DBMS_OUTPUT subprograms
Subprogram | Description |
---|---|
|
Disables message output. |
|
Enables message output. |
|
Retrieves one line from the buffer. |
|
Retrieves an array of lines from the buffer. |
|
Terminates a line created with |
|
Places a line in the buffer. |
|
Places a partial line in the buffer. |
The DBMS_PREPROCESSOR
package provides an interface to print or retrieve the source text of a PL/SQL unit after processing of conditional compilation directives.
Table 8-4 describes the DBMS_PREPROCESSOR
subprograms.
The DBMS_RANDOM
package provides a built-in random number generator.
Table 8-5 describes the DBMS_RANDOM
subprograms.
Table 8-5 DBMS_RANDOM subprograms
Subprogram | Description |
---|---|
|
Initializes the package with a seed value (deprecated). |
|
Returns random numbers in a normal distribution. |
|
Generates a random number (deprecated). |
|
Resets the seed. |
|
Gets a random string. |
|
Terminates the package (deprecated). |
|
There are two overloaded versions. In the first, it gets a random number greater than or equal to 0 and less than 1, with 38 digits to the right of the decimal point (38-digit precision). In the second, it gets a random within specified low and high limits. |
The DBMS_SQL
package provides an interface for using dynamic SQL to accomplish any of the following:
Execute data manipulation language (DML) and data definition language (DDL) statements.
Execute PL/SQL anonymous blocks.
Call PL/SQL stored procedures and functions.
This package does not support pre-defined data types and overloads with data types that are not supported in TimesTen, such as UROWID
, time zone features, ADT, database-level collections, and edition overloads. For more information on the supported data types in TimesTen PL/SQL, see "Understanding the data type environments".
Table 8-6 describes the DBMS_SQL
subprograms.
Table 8-6 DBMS_SQL subprograms
Subprogram | Description |
---|---|
|
Binds a given value to a given collection. |
|
Binds a given value to a given variable. |
|
Closes a given cursor and frees memory. |
|
Returns the value of the cursor element for a given position in a cursor. |
|
Returns a selected part of a Important: Because TimesTen does not support the |
|
Defines a collection to be selected from the given cursor. Use with |
|
Defines a column to be selected from the given cursor. Use with |
|
Defines a Important: Because TimesTen does not support the |
|
Describes the columns for a cursor opened and parsed through the |
|
Describes the specified column. Use as an alternative to |
|
Describes the specified column. Use as an alternative to |
|
Executes a given cursor. |
|
Executes a given cursor and fetches rows. |
|
Fetches a row from a given cursor. |
|
Returns |
|
Returns the byte offset in the SQL statement text where the error occurred. |
|
Returns a cumulative count of the number of rows fetched. |
|
Returns |
|
Returns the SQL function code for the statement. |
|
Returns the cursor ID number of a new cursor. |
|
Parses a given statement. |
|
Takes an opened (by |
|
Takes an opened, parsed, and executed cursor (by |
|
Returns value of a named variable for a given cursor. |
The DBMS_UTILITY
package provides a variety of utility subprograms.
Subprograms are not supported (and not listed here) for features that TimesTen does not support.
Table 8-7 describes DBMS_UTILITY
subprograms.
Table 8-7 DBMS_UTILITY subprograms
Subprogram | Description |
---|---|
|
Canonicalizes a given string. |
|
Converts a comma-delimited list of names into an associative array (index-by table) of names. |
Compiles all procedures, functions, packages, and views in the specified database schema. |
|
|
Returns version information for the database. The procedure returns |
|
Formats the current call stack. |
|
Formats the backtrace from the point of the current error to the exception handler where the error is caught. |
|
Formats the current error stack. |
|
Returns the current CPU time in hundredths of a second. |
|
Shows the dependencies on the objects passed in. |
|
Returns the endianness of your database platform. |
|
Computes a hash value for a given string. |
|
Computes the hash value for a given string using the MD5 algorithm. |
|
Returns the current time in hundredths of a second. |
Invalidates a database object and optionally modifies the PL/SQL compiler parameter settings for the object. |
|
|
Checks the setting of a specified bit in a |
|
Resolves the given name of the following form: [[a.]b.]c[@dblink] Where Do not use |
|
Calls the parser to parse the given name of the following form: "a [.b [.c ]][@dblink]" Strips double quotes or converts to uppercase if there are no quotes. Ignores comments and does not perform semantic analysis. Missing values are Do not use |
|
Converts an associative array (index-by table) of names into a comma-delimited list of names. |
|
Validates the object described by either owner, name and namespace, or object ID. |
The TT_DB_VERSION
package contains boolean constants indicating the current TimesTen release.
Table 8-8 describes the TT_DB_VERSION
constants.
The primary use case for the TT_DB_VERSION
and UTL_IDENT
packages is for conditional compilation.
Table 8-8 TT_DB_VERSION Constants
Name | Description |
---|---|
|
Boolean that is |
|
Boolean that is |
See "Examples" in Oracle TimesTen In-Memory Database PL/SQL Packages Reference for an example that uses TT_DB_VERSION
and UTL_IDENT
.
The UTL_FILE
package enables PL/SQL programs the ability to read and write operating system text files.
In the current release, this package is restricted to access of a pre-defined temporary directory only. Refer to the Oracle TimesTen In-Memory Database Release Notes for details.
Note:
Users do not have execute permission onUTL_FILE
by default. To use UTL_FILE
in TimesTen, an ADMIN
user or instance administrator must explicitly grant EXECUTE
permission on it, such as in the following example:
GRANT EXECUTE ON SYS.UTL_FILE TO scott;
Table 8-9 describes the UTL_FILE
subprograms.
Table 8-9 UTL_FILE subprograms
Subprogram | Description |
---|---|
|
Closes a file. |
|
Closes all file handles. |
|
Copies a contiguous portion of a file to a newly created file. |
|
Physically writes all pending output to a file. |
|
Reads and returns the attributes of a disk file. |
|
Returns the current relative offset position (in bytes) within a file. |
|
Opens a file for input or output. |
|
Opens a file in Unicode for input or output. |
|
With sufficient privilege, deletes a disk file. |
|
Renames an existing file to a new name (similar to the UNIX |
|
Adjusts the file pointer forward or backward within the file by the number of bytes specified. |
|
Reads text from an open file. |
|
Reads text in Unicode from an open file. |
|
Reads a |
|
Determines if a file handle refers to an open file. |
|
Writes one or more operating system-specific line terminators to a file. |
|
Writes a string to a file. |
|
Writes a line to a file and appends an operating system-specific line terminator. |
|
Writes a Unicode line to a file. |
|
Writes a Unicode string to a file. |
|
Accepts as input a |
|
This is similar to the |
|
This is similar to the |
The UTL_IDENT
package indicates whether PL/SQL is running on TimesTen, an Oracle client, an Oracle server, or Oracle Forms. Each of these has its own version of UTL_IDENT
with appropriate settings for the constants.
Table 8-10 shows the UTL_IDENT
settings for TimesTen.
The primary use case for the UTL_IDENT
package is for conditional compilation, resembling the following:
$if utl_ident.is_oracle_server $then [...Run code supported for Oracle Database...] $elsif utl_ident.is_timesten $then [...code supported for TimesTen Database...] $end
Table 8-10 UTL_IDENT Constants
Name | Description |
---|---|
|
|
|
|
|
|
|
|
See "Examples" in Oracle TimesTen In-Memory Database PL/SQL Packages Reference for an example that uses TT_DB_VERSION
and UTL_IDENT
.
The UTL_RAW
package provides SQL functions for manipulating RAW
data types.
Table 8-11 describes the UTL_RAW
subprograms.
Table 8-11 UTL_RAW subprograms
Subprogram | Description |
---|---|
|
Performs bitwise logical "and" of two |
|
Performs bitwise logical "complement" of a |
|
Performs bitwise logical "or" of two |
|
Performs bitwise logical "exclusive or" of two |
|
Returns the |
|
Returns the |
|
Returns the |
|
Returns the |
|
Casts the |
|
Casts the |
|
Casts the |
|
Casts the |
|
Casts a |
|
Casts a |
|
Casts a |
|
Compares two |
|
Concatenates up to 12 |
|
Converts a |
|
Copies a |
|
Returns the length in bytes of a |
|
Overlays the specified portion of a target |
|
Reverses a byte-sequence in a |
|
Returns a substring of a |
|
Translates the specified bytes from an input |
|
Converts the specified bytes from an input |
|
Returns a |
The UTL_RECOMP
package recompiles invalid PL/SQL modules. This is particularly useful after a major-version upgrade that typically invalidates all PL/SQL objects.
Table 8-12 describes the UTL_RECOMP
subprograms.
Important:
To use this package, you must be the instance administrator and specifySYS.UTL_RECOMP
.Table 8-12 UTL_RECOMP subprograms
Name | Description |
---|---|
|
Recompiles invalid objects in a given schema, or all invalid objects in the database, in parallel. Note: Because TimesTen does not support |
|
Recompiles invalid objects in a given schema, or all invalid objects in the database, serially. |