ALLBASE/SQL Reference Manual (36216-90216)

468 Chapter11
SQL Statements E - R
PREPARE
Description
You cannot use the PREPARE statement to preprocess the following statements:
ADVANCE BEGIN DECLARE SECTION BEGIN WORK
CLOSE COMMIT WORK CONNECT
DECLARE CURSOR DELETE WHERE CURRENT DESCRIBE
DISCONNECT END DECLARE SECTION EXECUTE
EXTRACT FETCH INCLUDE
OPEN PREPARE RELEASE
ROLLBACK WORK SET CONNECTION SET SESSION
SET TRANSACTION SETOPT START DBE
STOP DBE SQLEXPLAIN UPDATE WHERE CURRENT
TERMINATE USER WHENEVER
You cannot interactively prepare a SELECT statement.
A statement to be dynamically preprocessed in an application program must be
terminated with a semicolon.
You cannot prepare a statement which contains host variables. Dynamic parameters
should be used instead. (Use PREPARE without the REPEAT option.)
In an application program, a dynamically preprocessed statement (PREPARE without
the REPEAT option) is automatically deleted from the system at the end of the
transaction in which it was prepared. It cannot be executed in any other transaction.
When a PREPARE statement is issued interactively, the dynamically preprocessed
statement is stored in the system catalog until deleted by a DROP MODULE statement.
The statement is not stored, however, if you specify an owner name of TEMP.
If the IN
DBEFileSetName
clause is specified, but the module owner does not have
SECTIONSPACE authority for the specified DBEFileSet, a warning is issued and the
default SECTIONSPACE DBEFileSet is used instead. (Refer to syntax for the GRANT
statement and the SET DEFAULT DBEFILESET statement.)
Authorization
You do not need authorization to use the PREPARE statement. However, the authority
required to execute the dynamically preprocessed statement depends on whether the
statement is executed programmatically or interactively. Refer to the EXECUTE statement
authorization for details.
To specify a
DBEFileSetName
for a prepared section, the module owner must have
SECTIONSPACE authority on the referenced DBEFileSet.
Examples
1. Interactive use
PREPARE Statistics(1)
FROM 'UPDATE STATISTICS FOR TABLE PurchDB.Orders'
PREPARE Statistics(2)
FROM'UPDATE STATISTICS FOR TABLE PurchDB.OrderItems'