PREPARE statement [ESQL]
578
PREPARE statement [ESQL]
Use this statement to prepare a statement to be executed later, or used to
define a cursor.
PREPARE
statement-name
FROM
statement
…[ DESCRIBE
describe-type
INTO [ [ SQL ] DESCRIPTOR ]
descriptor
]
…[ WITH EXECUTE ]
statement-name
:
identifier
or
host-variable
statement
:string
or
host-variable
describe-type:
{ ALL | BIND VARIABLES | INPUT | OUTPUT | SELECT LIST }
…[ LONG NAMES [ [ OWNER. ]TABLE. ]COLUMN ]
| WITH VARIABLE RESULT ]
None.
Any statement previously prepared with the same name is lost.
The statement is dropped after use only if you use WITH EXECUTE and the
execution is successful. You should ensure that you DROP the statement
after use in other circumstances. If you do not, the memory associated with
the statement is not reclaimed.
"DECLARE CURSOR statement" on page 488
"DESCRIBE statement" on page 500
"OPEN statement" on page 570
"EXECUTE statement" on page 514
"DROP STATEMENT statement" on page 512
The PREPARE statement prepares a SQL statement from the statement and
associates the prepared statement with statement-name. This statement name
is referenced to execute the statement, or to open a cursor if the statement is
a SELECT statement. The statement-name may be a host variable of type
a_sql_statement_number defined in the
sqlca.h
header file that is
automatically included. If an identifier is used for the statement-name, only
one statement per module may be prepared with this statement-name.
If a host variable is used for statement-name, it must have the type short int.
There is a typedef for this type in
sqlca.h
called a_sql_statement_number.
This type is recognized by the SQL preprocessor and can be used in a
DECLARE section. The host variable is filled in by the database during the
PREPARE statement, and need not be initialized by the programmer.
Function
Syntax
Permissions
Side effects
See also
Description