SQL/MP Report Writer Guide

Selecting Data for a Report
HP NonStop SQL/MP Report Writer Guide527213-001
3-25
Preparing a SELECT Command
command to determine the system resources required to execute the query. For
descriptions of the PREPARE, EXECUTE, and EXPLAIN commands, see the SQL/MP
Reference Manual.
For example, suppose you want to print information about the orders from a customer
assigned to a specific sales representative. This report is produced each month for
sales representatives and all of their customers. You can create an command file that
contains a command to prepare the SELECT command.
This SELPREP file contains the following PREPARE command:
PREPARE SELCUSTINFO FROM
" SELECT * FROM SALES.CUSTOMER C, "
&" SALES.ORDERS R, "
&" SALES.ODETAIL OD, "
&" SALES.PARTS P "
&" WHERE C.CUSTNUM = R.CUSTNUM "
&" AND R.ORDERNUM = OD.ORDERNUM "
&" AND OD.PARTNUM = P.PARTNUM "
&" AND C.CUSTNUM = ? "
&" AND SALESREP = ?";
The SELECT command contains two unnamed parameters to be given values through
an EXECUTE command.
You can create another command file to produce the reports; this file is called
PRINTREP.
SET LIST_COUNT 0;
OUT_REPORT $S.#PRINTER
EXECUTE SELCUSTINFO USING 21, 223;
LIST ALL;
EXECUTE SELCUSTINFO USING 123, 226;
LIST ALL;
.
.
EXECUTE SELCUSTINFO USING 7777, 220;
LIST ALL;