SQL/MX Quick Start (G06.24+, H06.03+)

HP NonStop SQL/MX Quick Start523724-002
7-1
7
Using the Same SELECT Statement
Repeatedly
This section provides information about 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. When you end your session, however, 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 provide values for these parameters before
you execute the statement by using the SET PARAM command.
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.