Oracle® TimesTen In-Memory Database PL/SQL Developer's Guide Release 11.2.1 Part Number E13076-02 |
|
|
View PDF |
"PL/SQL Language Elements" in Oracle Database PL/SQL Language Reference describes language elements that are supported in Oracle.
The purpose of this chapter is to summarize these language elements and indicate their support in TimesTen. Additional TimesTen support considerations are also presented:
Table 10-1 lists the same PL/SQL language elements as in "PL/SQL Language Elements" in Oracle Database PL/SQL Language Reference, 11g Release 1 (11.1). You can refer to that document for detailed information on the PL/SQL language elements. For each element:
The first column lists the language element.
The second column includes a brief description of the element.
The third column indicates if the element is supported in TimesTen.
The fourth column provides examples and further comments, and refers to additional discussion and examples earlier in this document or in other documents.
Note:
Also refer to Table 10-2, "Additional differences between TimesTen PL/SQL and Oracle PL/SQL" for additional support considerations.Table 10-1 PL/SQL Language Elements
Element Name | Description | Supported | Example/Comment |
---|---|---|---|
Assignment statement |
Sets current value of a variable, parameter, or element. |
Y |
|
AUTONOMOUS_TRANSACTION pragma |
Marks a routine as autonomous. |
N |
TimesTen does not support autonomous transactions. |
Block declaration |
Basic unit of a PL/SQL source program. |
Y |
See "PL/SQL blocks". |
CASE statement |
Evaluates an expression, compares it against several values, and takes action according to the comparison that is |
Y |
|
CLOSE statement |
Closes cursor or cursor variable. |
Y |
See Example 2-13, "Using a cursor to retrieve information about an employee" (among others). |
Collection definition |
Specifies a collection, which is an ordered group of elements, all of the same type. |
Y |
Examples include: associative arrays (index-by tables), nested tables, and varrays. While TimesTen supports these types, it does not support passing them between PL/SQL and applications written in other languages. See "Using collections". |
Collection methods |
Built-in subprograms that operate on collections and are called using "dot" notation. |
Y |
See "Using Collection Methods" in Oracle Database PL/SQL Language Reference. Examples include COUNT, DELETE, EXISTS, EXTEND, FIRST, LAST, LIMIT, NEXT, PRIOR, and TRIM. |
Comments |
Text included within your code for explanatory purposes. |
Y |
Single-line and multi-line comments are supported. |
COMMIT statement |
Ends the current transaction and makes permanent all changes performed in the transaction. |
Y |
TimesTen SQL statement. See "COMMIT" in Oracle TimesTen In-Memory Database SQL Reference. Important: COMMIT and ROLLBACK statements close all cursors in TimesTen. |
Constant and variable declarations |
Specify constants and variables to be used in PL/SQL code, in the declarative part of any PL/SQL block, subprogram, or package. |
Y |
|
CONTINUE statement |
Exits the current iteration of a loop and transfers control to the next iteration. |
Y |
See "CONTINUE statement". |
Cursor attributes |
Appended to the cursor or cursor variable to return useful information about the execution of a data manipulation statement. |
Y |
Explicit cursors and cursor variables have four attributes: %FOUND, %ISOPEN, %NOTFOUND, %ROWCOUNT. The implicit cursor (SQL) has additional attributes: %BULK_ROWCOUNT, %BULK_EXCEPTIONS. See "Using the %ROWCOUNT and %NOTFOUND attributes" and "Using FORALL with SQL%BULK_ROWCOUNT". Also see "Cursor Attributes" in Oracle Database PL/SQL Language Reference. |
Cursor declaration |
Declares a cursor. To execute a multi-row query, TimesTen opens an unnamed work area that stores processing information. A cursor lets you name the work area, access the information, and process the rows individually. |
Y |
|
Cursor variables (REF CURSORs) |
Act as handles to cursors over SQL result sets. |
Y |
TimesTen supports OUT REF CURSORs, one per statement. See "PL/SQL REF CURSORs". |
DELETE statement |
Deletes rows from a table. |
Y |
TimesTen SQL statement. See "DELETE" in Oracle TimesTen In-Memory Database SQL Reference. |
EXCEPTION_INIT pragma |
Associates a user-defined exception with a TimesTen error number. |
Y |
See "EXCEPTION_INIT Pragma" in Oracle Database PL/SQL Language Reference. |
Exception definition |
Specifies an exception, which is a runtime error or warning condition. Can be predefined or user-defined. |
Y |
Predefined conditions are raised implicitly. User-defined exceptions are raised explicitly by the RAISE statement. To handle raised exceptions, write separate routines called "exception handlers". |
EXECUTE IMMEDIATE statement |
Builds and executes a dynamic SQL statement in a single operation. |
Y |
TimesTen supports this to execute SQL DML and DDL statements, but not to execute PL/SQL. See "Dynamic SQL in PL/SQL (EXECUTE IMMEDIATE statement)". |
EXIT statement |
Exits a loop and transfers control to the end of the loop. |
Y |
See Example 7-3 (among others). |
Expression definition |
Specifies an expression, which is a combination of operands (variables, constants, literals, operators, and so on) and operators. The simplest expression is a single variable. |
Y |
|
FETCH statement |
Retrieves rows of data from the result set of a multi-row query. |
Y |
See Example 2-13 (among others). |
FORALL statement |
Bulk-binds input collections before sending them to the SQL engine. |
Y |
|
Function declaration and definition |
Specifies a subprogram or stored program that can be declared and defined in a PL/SQL block or package and returns a single value. |
Y |
A function or procedure must be executed in an anonymous block. It cannot be executed through a CALL statement or from any other SQL statement in TimesTen. Use the CREATE FUNCTION statement in TimesTen SQL to create stored functions. See "PL/SQL procedures and functions". Also see "CREATE FUNCTION" in Oracle TimesTen In-Memory Database SQL Reference. Also see the table entry below for "Procedure declaration and definition". |
GOTO statement |
Branches unconditionally to a statement label or block label. |
Y |
See "GOTO Statement" in Oracle Database PL/SQL Language Reference. |
IF statement |
Executes or skips a sequence of statements depending on the value of the associated boolean expression. |
Y |
|
INLINE pragma |
Specifies whether a subprogram call is to be inline. |
Y |
See "INLINE Pragma" in Oracle Database PL/SQL Language Reference. |
INSERT statement |
Inserts one or more rows of data into a table. |
Y |
TimesTen SQL statement. See "Example using the INSERT statement". Also see "INSERT" in Oracle TimesTen In-Memory Database SQL Reference. |
Literal declaration |
Specifies a numeric, character string, or boolean value. |
Y |
Examples: Numeric literal: 135 String literal: 'TimesTen' |
LOCK TABLE statement |
Locks database tables in a specified lock mode. |
N |
TimesTen does not support the LOCK TABLE statement. |
LOOP statement |
Executes a sequence of statements multiple times. Can be used, for example, in implementing a FOR loop or WHILE loop. |
Y |
See Example 2-8, "Using a WHILE loop". Also see "LOOP Statements" in Oracle Database PL/SQL Language Reference. |
MERGE statement |
Allows you to select rows from one or more sources for update or insertion into a target table. |
Y |
TimesTen SQL statement. See "MERGE" in Oracle TimesTen In-Memory Database SQL Reference. |
NULL statement |
A no-operation statement. Passes control to the next statement without performing any action. |
Y |
See "NULL Statement" in Oracle Database PL/SQL Language Reference. Also, one is used in Example 3-3. |
Object type declaration |
Specifies a custom object type, which is created in SQL and stored in the database. |
N |
Object types are not supported at the database level. For example, CREATE TYPE is not supported. |
OPEN statement |
Executes the query associated with a cursor. Allocates database resources to process the query, and identifies the result set. |
Y |
See Example 2-13, "Using a cursor to retrieve information about an employee". |
OPEN-FOR statement |
Executes the SELECT statement associated with a cursor variable (REF CURSOR). Positions the cursor variable before the first row in the result set. |
Y |
See Example 3-4, "Fetch rows from result set of a dynamic multirow query". |
Package declaration |
Specifies a package, which is a database object that groups logically related PL/SQL types, items, and subprograms. |
Y |
TimesTen SQL statements CREATE PACKAGE and CREATE PACKAGE BODY. See "SQL Statements" in Oracle TimesTen In-Memory Database SQL Reference for information about these statements. Also see "PL/SQL packages". |
Procedure declaration and definition |
Specifies a subprogram or stored program that can be declared and defined in a PL/SQL block or package and performs a specific action. |
Y |
A procedure or function must be executed in an anonymous block. It cannot be executed through a CALL statement or from any other SQL statement in TimesTen. Use the CREATE PROCEDURE statement in TimesTen SQL to create stored procedures. See "PL/SQL procedures and functions". Also see "CREATE PROCEDURE" in Oracle TimesTen In-Memory Database SQL Reference. Also see the table entry above for "Function declaration and definition". |
RAISE statement |
Stops normal execution of a PL/SQL block or subprogram and transfers control to an exception handler. |
Y |
|
Record definition |
Defines a record, which is a composite variable that stores data values of different types (similar to a database row). |
Y |
See "Using records". |
RESTRICT_REFERENCES pragma |
Asserts that a subprogram (usually a function) in a package specification or object type specification does not read or write database tables or package variables. |
N |
TimesTen ignores this. |
RETURN statement |
Immediately completes the execution of a subprogram and returns control to the invoker. Execution resumes with the statement following the subprogram call. |
Y |
See "RETURN Statement" in Oracle Database PL/SQL Language Reference. |
RETURNING INTO clause |
Specifies the variables in which to store the values returned by the statement to which the clause belongs. |
Y |
TimesTen clause. See "RETURNING INTO clause" and "Examples using RETURNING INTO". |
ROLLBACK statement |
Undoes database changes made during the current transaction. |
Y |
TimesTen SQL statement. See "ROLLBACK" in Oracle TimesTen In-Memory Database SQL Reference. Important: COMMIT and ROLLBACK statements close all cursors in TimesTen. |
%ROWTYPE attribute |
Provides a record type that represents a row in a database table. |
Y |
See Example 2-2. |
SAVEPOINT statement |
Names and marks the current point in the processing of a transaction. |
N |
TimesTen does not support savepoints. |
SELECT INTO statement |
Retrieves values from one row of a table (SELECT) and then stores the values in either variables or a record. With the BULK COLLECT clause (discussed in Table 10-2 below), this statement retrieves an entire result set at once. |
Y |
See Example 2-3, "Using SELECT INTO to assign values to variables". Also see "Querying Data with PL/SQL" in Oracle Database PL/SQL Language Reference. |
SERIALLY_REUSABLE pragma |
Indicates that package state is needed only for the duration of one call to the server. |
N |
TimesTen does not support the SERIALLY_REUSABLE pragma. |
SET TRANSACTION statement |
Begins a read-only or read/write transaction. |
N |
TimesTen does not support the SET TRANSACTION statement. |
SQL cursor |
Either explicit or implicit, is used to handle the result set of a SELECT statement. |
Y |
|
SQLCODE function |
Returns number code of the most recent exception. |
Y |
Given the same error condition, error codes returned by the built-in function SQLCODE are the same in TimesTen as in Oracle, although the SQLERRM returns may be different. This is also noted in "TimesTen error messages and SQL codes". |
SQLERRM function |
Returns the error message associated with the error-number argument. |
Y |
Given the same error condition, error messages returned by the built-in function SQLERRM are not necessarily the same in TimesTen as in Oracle, although SQLCODE returns are the same. This is also noted in "TimesTen error messages and SQL codes". |
%TYPE attribute |
Lets you use the data type of a field, record, nested table, database column, or variable in your own declarations, rather than hardcoding the data type. Particularly useful when declaring variables, fields, and parameters that refer to database columns. |
Y |
|
UPDATE statement |
Updates the values of one or more columns in all rows of a table or in rows that satisfy a search condition. |
Y |
TimesTen SQL statement. See "UPDATE" in Oracle TimesTen In-Memory Database SQL Reference. |
Table 10-2 provides a summary of additional support considerations for features that are supported in TimesTen. Comments explain differences between PL/SQL in TimesTen and PL/SQL in Oracle (Release 11.1.0.7).
Table 10-2 Additional differences between TimesTen PL/SQL and Oracle PL/SQL
Feature | Comment |
---|---|
ALTER {PROCEDURE| FUNCTION | PACKAGE} |
Syntax and semantics are the same as in Oracle. You can refer to information about these statements in "SQL Statements" in Oracle TimesTen In-Memory Database SQL Reference. |
ALTER SESSION statement |
You can use ALTER SESSION to set some PL/SQL connection attributes as discussed in "PL/SQL connection attributes". For more information on this statement in TimesTen, see "ALTER SESSION" in Oracle TimesTen In-Memory Database SQL Reference. |
Built-in functions and SQL functions |
|
BULK COLLECT |
This clause can be used with the SELECT statement in PL/SQL to retrieve rows without using a cursor. See "FORALL and BULK COLLECT operations" and "Examples using FORALL and BULK COLLECT". |
CALL statement |
In TimesTen, use the CALL statement to execute TimesTen built-in procedures. In Oracle, use the CALL statement to execute PL/SQL stored procedures and functions. |
Connection attributes |
Equivalent to initialization parameters in Oracle. See "PL/SQL connection attributes". Also see "Data Store Attributes" in Oracle TimesTen In-Memory Database Reference. |
CREATE FUNCTION |
The CREATE FUNCTION statement is supported in TimesTen, but the AS LANGUAGE, AS EXTERNAL, and PIPELINED clauses are not supported. See "PL/SQL procedures and functions". Also see "CREATE FUNCTION" in Oracle TimesTen In-Memory Database SQL Reference. You are not required to run |
CREATE LIBRARY |
The CREATE LIBRARY statement is not supported in TimesTen. |
CREATE PACKAGE [BODY] |
Syntax and semantics are the same as in Oracle. See "PL/SQL packages". Also see "CREATE PACKAGE" and "CREATE PACKAGE BODY" in Oracle TimesTen In-Memory Database SQL Reference. You are not required to run |
CREATE PROCEDURE |
CREATE PROCEDURE statement is supported in TimesTen, but the AS LANGUAGE and AS EXTERNAL clauses are not supported. See "PL/SQL procedures and functions". Also see "CREATE PROCEDURE" in Oracle TimesTen In-Memory Database SQL Reference. You are not required to run |
Data type support |
|
DROP { PROCEDURE | FUNCTION| PACKAGE} |
Syntax and semantics are the same as in Oracle. You can refer to information about these statements in "SQL Statements" in Oracle TimesTen In-Memory Database SQL Reference. |
Error reporting |
TimesTen applications report errors using Oracle error codes instead of TimesTen error codes. The error messages that accompany the error codes are either TimesTen error messages or Oracle error messages. |
Executing PL/SQL from SQL |
In TimesTen, you cannot execute PL/SQL from either a static or dynamic SQL statement. |
Executing PL/SQL from client applications |
Oracle TimesTen In-Memory Database supports ODBC, OCI, Pro*C, TTClasses (a set of TimesTen C++ classes), and JDBC. Refer to documentation for those programming interfaces, as desired. |
Native Dynamic SQL execution |
In TimesTen, in addition to Oracle functionality, the EXECUTE IMMEDIATE statement can be used to execute TimesTen built-in procedures and TimesTen-specific SQL features (such as SELECT FIRST). |
In TimesTen (unlike in Oracle), use of non-ASCII character sets in names of tables, columns, procedures, functions, and other database objects is not supported. |
|
In TimesTen (unlike in Oracle), quoted non-uppercase names of tables, columns, procedures, functions, and other database objects are not supported (such as create or replace procedure "MixedCase" as begin ... end; / |
|
Result cache |
Oracle TimesTen In-Memory Database does not support the PL/SQL function result cache. |
SOUNDEX SQL function |
TimesTen does not support this function (which returns a character string containing the phonetic representation of a |
SQL constructs, misc. |
Oracle TimesTen In-Memory Database does not support the CREATE TYPE statement, database links, or triggers. |
Supplied packages |
Oracle TimesTen In-Memory Database provides a subset of the Oracle PL/SQL supplied packages. |
System tables and views |
Oracle TimesTen In-Memory Database supports a subset of the Oracle system tables and views. See "System and Replication Tables" in Oracle TimesTen In-Memory Database SQL Reference. |
In TimesTen, use this built-in procedure to return statistics about library cache performance and activity. See "ttPLSQLMemoryStats" in Oracle TimesTen In-Memory Database Reference. In Oracle, use the V$LIBRARYCACHE system view to retrieve the same statistical information. |