SQL/MX Quick Start (H06.04+, J06.03+)
HP NonStop SQL/MX Quick Start—540438-001
7-1
7
Using the Same SELECT Statement
Repeatedly
This section describes how to prepare and execute statements and use parameter
values.
Preparing to Execute a Statement Repeatedly
You can prepare a statement (assigning a name to it) and execute it repeatedly during
your MXCI session. However, when you end your session, the prepared statement is
no longer available.
Prepared statements are most useful if they contain parameters. A parameter is a
name preceded by a question mark. You use the SET PARAM command to provide
values for these parameters before you execute the statement.
Example
Suppose you have a stack of handwritten orders, and you want to verify that the
information about certain parts is correct in the database. In this example, the
statement is prepared and assigned the name CKO. The parameters are ?order and
?part:
PREPARE CKO FROM
SELECT * FROM ODETAIL
WHERE ORDERNUM = ?order AND PARTNUM = ?part;
--- SQL command prepared.










