SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
S-37
Examples—SET PARAM
Examples—SET PARAM
In this example, the SELECT statement in the FINDSUP2 file finds suppliers of a
specified part. The suppliers are located in a specified state.
VOLUME $VOL1.INVENT;
SELECT S.SUPPNUM, SUPPNAME FROM SUPPLIER S, PARTSUPP
WHERE S.SUPPNUM = PARTSUPP.SUPPNUM AND
PARTNUM = ?PN AND STATE = ?ST;
Before you can execute the SELECT statement, you must specify the state and
part number with a SET PARAM command, as shown:
>> SET PARAM ?ST TEXAS, ?PN 4103;
>> OBEY FINDSUP2;
You do not have to enclose TEXAS in quotation marks because SQLCI determines
from the STATE column definition that the column has a character data type.
In these examples, the dates are in timestamp format and the OBEY command file
INSORD contains these commands:
INSERT INTO SALES.ORDERS
VALUES (?ONUM, ?TODAY, ?DDATE, ?REP, ?CUSTNUM);
To insert an order, set the order date to the current day and enter a specific
delivery date using the date conversion functions. The numbers of the order, sales
representative, and customer are entered as numeric literals:
>> SET PARAM ?ONUM 800661, ?TODAY CURRENT_TIMESTAMP,
+> ?DDATE COMPUTE_TIMESTAMP ( 5/23/1988 ),
+> ?REP 221, ?CUSTNUM 7654;
>> OBEY INSORD;
These values are inserted in ORDERS:
Suppose that you have set values for some of the parameters of the previous
INSERT command using the PARAM command before starting SQLCI:
4> PARAM ONUM 400410, CUSTNUM 7654
5> SQLCI
ORDERNUM 800661
ORDER_DATE (timestamp for current date and time)
DELIV_DATE (timestamp for 5/23/88)
SALESREP 221
CUSTNUM 7654