SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-62
COBOL Example of IF Statement
COBOL Example of IF Statement
These INSERT and SELECT statements execute sequentially for new orders.
Otherwise, the SELECT statement returns information about the current customer:
EXEC SQL
BEGIN
IF :hv_now_ordernum <> 0
THEN
INSERT INTO SALES.ORDERS
(ORDERNUM, ORDER_NAME, DELIV_DATE,...)
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 ...
INTO ...
WHERE CUSTNUM = :hv_current_custnum;
END IF;
END
END-EXEC.