Oracle TimesTen In-Memory Database supplies 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.
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 packages STANDARD, DBMS_STANDARD, and PLITBLM are not documented here. Subprograms belonging to these packages are part of the PL/SQL language.
All users have EXECUTE privilege for packages described in this chapter, except as noted for UTL_FILE and UTL_RECOMP in those sections.
The DBMS_LOCK package provides an interface to lock-management services. In the current release, TimesTen supports only the sleep feature.
Table 8-1 describes the supported DBMS_LOCK subprogram.
Table 8-1 DBMS_OUTPUT 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-2 describes the DBMS_OUTPUT subprograms.
Table 8-2 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-3 describes the DBMS_PREPROCESSOR subprograms.
The DBMS_RANDOM package provides a built-in random number generator.
Table 8-4 describes the DBMS_RANDOM subprograms.
Table 8-4 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).  | 
| 
 
  | 
 The   | 
The DBMS_SQL package provides an interface for using dynamic SQL to parse data manipulation language (DML) or data definition language (DDL) statements using PL/SQL.
This package does not support pre-defined data types and overloads with data types that are not supported in TimesTen, such as LOBs, 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-5 describes the DBMS_SQL subprograms.
Table 8-5 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 cumulative count of the number of rows fetched.  | 
| 
 
  | 
 TimesTen does not support   | 
| 
 
  | 
 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-6 describes DBMS_UTILITY subprograms.
Table 8-6 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.  | 
|
| 
 
  | 
 Returns bit setting.  | 
| 
 
  | 
 Resolves the given name of the form: [[a.]b.]c[@dblink] Where  Do not use   | 
| 
 
  | 
 Calls the parser to parse the given name: "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 is a TimesTen-specific package that indicates the version number and release number for the Oracle TimesTen In-Memory Database.
Table 8-7 describes the TT_DB_VERSION constants.
The primary use case for the TT_DB_VERSION and UTL_IDENT packages is for conditional compilation. See "UTL_IDENT" for an example.
Table 8-7 TT_DB_VERSION Constants
| Name | Description | 
|---|---|
| 
 
  | 
 Equals the major release number of the Oracle TimesTen In-Memory Database.  For example, for the Oracle TimesTen In-Memory Database, Release 11.2.1.0,   | 
| 
 
  | 
 Equals the minor release number of the Oracle TimesTen In-Memory Database product.  For example, for the Oracle TimesTen In-Memory Database, Release 11.2.1.0,   | 
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-8 describes the UTL_FILE subprograms.
Table 8-8 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-9 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
See Example 8-1 below.
| Name | Description | 
|---|---|
| 
 
  | 
 
  | 
| 
 
  | 
 
  | 
| 
 
  | 
 
  | 
| 
 
  | 
 
  | 
Example 8-1 Using UTL_IDENT and TT_DB_VERSION
This example uses the UTL_IDENT and TT_DB_VERSION packages to show information about the database being used. For the current release, it displays either "Oracle Database 11.2" or "TimesTen 11.2.1". The conditional compilation trigger character, $, identifies code that is processed before the application is compiled.
Command> run what_db.sql
 
create or replace function what_db
return varchar2
as
 dbname varchar2(100);
 version varchar2(100);
begin
$if utl_ident.is_timesten
$then
 dbname := 'TimesTen';
 version := substr(tt_db_version.version, 1, 2) ||
            '.' ||
            substr(tt_db_version.version, 3, 1) ||
            '.' ||
            substr(tt_db_version.version, 4, 1);
$elsif utl_ident.is_oracle_server
$then
 dbname := 'Oracle Database';
 version := dbms_db_version.version || '.' || dbms_db_version.release;
$else
 dbname := 'Non-database environment';
 version := '';
$end
 return dbname || ' ' || version;
end;
/
 
Function created.
 
set serveroutput on;
 
begin
dbms_output.put_line(what_db());
end;
/
 
TimesTen 11.2.1
 
PL/SQL procedure successfully completed.
The UTL_RAW package provides SQL functions for manipulating RAW data types.
Table 8-10 describes the UTL_RAW subprograms.
Table 8-10 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   | 
| 
 
  | 
 Converts a   | 
| 
 
  | 
 Converts a   | 
| 
 
  | 
 Converts 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-11 describes the UTL_RECOMP subprograms.
Important:
To use this package, you must be the instance administrator and specifySYS.UTL_RECOMP.Table 8-11 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.  |