SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Simple and Compound Statements
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
5-17
Using PROTOTYPE Host Variables as Table Names
 (ORDERNUM, ORDER_DATE, DELIV_DATE, SALESREP, CUSTNUM) 
 VALUES (:hv_new_ordernum, :hv_orderdate, :hv_delivdate, 
 :hv_salesrep, :hv_custnum); 
 SELECT CUSTNUM, CUSTNAME, STREET, CITY, STATE, POSTCODE 
 INTO :hv_custnum, :hv_custname, 
 :hv_street, :hv_city, :hv_state, :hv_postcode
 FROM SALES.CUSTOMER 
 WHERE CUSTNUM = :hv_custnum;
ELSE 
 SELECT CUSTNUM, CUSTNAME, STREET, CITY, STATE, POSTCODE 
 INTO :hv_custnum, :hv_custname, 
 :hv_street, :hv_city, :hv_state, :hv_postcode
 FROM SALES.CUSTOMER 
 WHERE CUSTNUM = :hv_current_custnum;
END IF; 
END; 
...
EXEC SQL 
BEGIN
IF :hv-new-ordernum <> 0 
THEN 
 INSERT INTO SALES.ORDERS 
 (ORDERNUM, ORDER_DATE, DELIV_DATE, SALESREP, CUSTNUM) 
 VALUES (:hv-new-ordernum, :hv-orderdate, :hv-delivdate, 
 :hv-salesrep, :hv-custnum); 
 SELECT CUSTNUM, CUSTNAME, STREET, CITY, STATE, POSTCODE 
 INTO :hv-custnum, :hv-custname, 
 :hv-street, :hv-city, :hv-state, :hv-postcode
 FROM SALES.CUSTOMER 
 WHERE CUSTNUM = :hv-custnum;
ELSE 
 SELECT CUSTNUM, CUSTNAME, STREET, CITY, STATE, POSTCODE 
 INTO :hv-custnum, :hv-custname, 
 :hv-street, :hv-city, :hv-state, :hv-postcode
 FROM SALES.CUSTOMER 
 WHERE CUSTNUM = :hv-current-custnum;
END IF; 
END END-EXEC.
Using PROTOTYPE Host Variables as Table 
Names
You can dynamically change the name of a table or view in an embedded SQL 
statement by using a host variable to provide the table name during execution. This 
capability enables late name resolution. For more information, see Late Name 
Resolution on page 8-6.
COBOL










