SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-159
PREPARE Statement
PREPARE Statement
Considerations for PREPARE
MXCI Examples of PREPARE
C Examples of PREPARE
COBOL Examples of PREPARE
The PREPARE statement compiles a dynamic SQL statement for later execution with
the EXECUTE statement. You can use PREPARE in an MXCI session or in an
embedded SQL program.
The application must supply a name to be associated with the prepared statement.
You can also use PREPARE to check the syntax of a statement without executing the
statement in MXCI.
statement-name
is an SQL identifier that specifies a name to be used for the prepared statement.
See Identifiers on page 6-52. If you specify the name of an existing prepared
statement, the new statement overwrites the previous one.
In MXCI, the statement name is not case-sensitive unless you delimit it within
double quotes.
In embedded SQL, the statement name is case-sensitive. For example, the
statement named findemp is not equivalent to the statement named FINDEMP.
statement
specifies the SQL statement to prepare.
ext-statement-name
is a value-specification—a host variable with character data type (for
example, :stmt). When PREPARE executes, the content of the value
specification identifies the statement that can be executed at a later time with
EXECUTE. If the statement name corresponds to the name of a previously
prepared statement, the new prepared statement overwrites the previous one.
PREPARE statement-name FROM statement
PREPARE statement-name FROM SQL-statement-variable
SQL-statement-name is:
statement-name | ext-statement-name
ext-statement-name is:
[GLOBAL | LOCAL] value-specification
C/COBOL
MXCI
MXCI
C/COBOL
MXCI
C/COBOL