1 – descriptor-name
Specifies the name of a structure declared in the host program
as an SQLDA to which SQL writes information about select list
items. Precompiled programs can use the embedded SQL statement
INCLUDE SQLDA to automatically insert a declaration of an SQLDA
structure, called SQLDA, in the program when it precompiles
the program. Programs that use the SQL module language must
explicitly declare an SQLDA. Either precompiled or SQL module
language programs can explicitly declare additional SQLDAs, but
must declare them with unique names.
2 – FROM
Syntax options:
FROM statement-string
FROM parameter
Specifies the SQL statement to be prepared for dynamic execution.
You either specify the statement string directly enclosed in
single quotation marks, or in a parameter (a host language
variable in a precompiled PREPARE statement or a formal parameter
in a PREPARE statement that is part of an SQL module language
procedure) that contains the statement string.
Whether specified directly or by a parameter, the statement
string must be a character string that is a dynamically
executable SQL statement. If you specify the statement string
directly, the maximum length is 1,024 characters. If you specify
the statement string as a parameter, the maximum length of the
statement string is 65,535 characters.
The form for the statement is the same as for embedded SQL
statements, except that:
o You must not begin the string with EXEC SQL.
o In places where SQL allows host language variables in an
embedded statement, you must specify parameter markers
instead.
If you try to prepare an invalid statement, you will find a value
in the SQLCODE, the SQLCODE field of the SQLCA, or the SQLSTATE
status parameter indicating an error.
The values returned to the SQLCODE field are described in the
Oracle Rdb SQL Reference Manual. Check the message vector to
see which error message was returned. If necessary, refer to the
error message explanations and user actions located by default in
the SQL HELP ERRORS.
Parameter markers are question marks (?) that denote parameters
in the statement string of a PREPARE statement. Parameter markers
are replaced by values in parameters or dynamic memory when the
prepared statement is executed by an EXECUTE or OPEN statement.
3 – SELECT_LIST_INTO
Specifies that SQL writes information about the number and data
type of select list items in the statement string to the SQLDA.
The SELECT LIST keywords clarify the effect of the INTO clause
and are optional.
Using the SELECT LIST clause in a PREPARE statement is an
alternative to issuing a separate DESCRIBE . . . INPUT statement.
See the DESCRIBE statement for more information.
The SELECT LIST clause in a PREPARE statement is deprecated
syntax. For more information about deprecated syntax, see the
Oracle Rdb SQL Reference Manual.
NOTE
The PREPARE statement LIST keyword is not related to the
LIST data type or list cursors.
4 – statement-name
Identifies the prepared version of the SQL statement specified in
the FROM clause. Depending on the type of SQL statement prepared,
DESCRIBE, EXECUTE, and dynamic DECLARE CURSOR statements can
refer to the statement name assigned in a PREPARE statement.
You can supply either a parameter or a compile-time statement
name. Specifying a parameter lets SQL supply identifiers to
programs at run time. Use an integer parameter to contain the
statement identifier returned by SQL, or a character string
parameter to contain the name of the statement that you pass
to SQL.
A single set of dynamic SQL statements (PREPARE, DESCRIBE,
EXECUTE, Extended Dynamic DECLARE CURSOR) can handle any
number of dynamically executed statements. If you decide to
use parameters, statements that refer to the prepared statement
(DESCRIBE, EXECUTE, extended dynamic DECLARE CURSOR) must also
use a parameter instead of the explicit statement name.
Refer to the DECLARE Dynamic_CURSOR statement for an example
demonstrating the PREPARE statement used with a dynamic DECLARE
CURSOR statement.
5 – statement-id-parameter
Identifies the prepared version of the SQL statement specified in
the FROM clause. Depending on the type of SQL statement prepared,
DESCRIBE, EXECUTE, and dynamic DECLARE CURSOR statements can
refer to the statement name assigned in a PREPARE statement.
You can supply either a parameter or a compile-time statement
name. Specifying a parameter lets SQL supply identifiers to
programs at run time. Use an integer parameter to contain the
statement identifier returned by SQL, or a character string
parameter to contain the name of the statement that you pass
to SQL.
A single set of dynamic SQL statements (PREPARE, DESCRIBE,
EXECUTE, Extended Dynamic DECLARE CURSOR) can handle any
number of dynamically executed statements. If you decide to
use parameters, statements that refer to the prepared statement
(DESCRIBE, EXECUTE, extended dynamic DECLARE CURSOR) must also
use a parameter instead of the explicit statement name.
See the DECLARE Dynamic_CURSOR statement for an example
demonstrating the PREPARE statement used with a dynamic DECLARE
CURSOR statement.