SQL/MX Programming Manual for C and COBOL (H06.10+, J06.03+)

Introduction
HP NonStop SQL/MX Programming Manual for C and COBOL544617-003
1-4
Using Host Variables
In this example, HV_THIS_CUSTOMER and HV_CUSTNAME are host variables:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 HV-THIS-CUSTOMER PIC 9(4) COMP.
01 HV-CUSTNAME PIC X(18).
EXEC SQL END DECLARE SECTION END-EXEC.
Using Host Variables
When you specify a host variable in an SQL statement, you must precede the host
variable name with a colon (:). In a 3GL statement, you do not need the colon.
This example shows a host variable in an embedded SQL statement:
Example
EXEC SQL SELECT custname
INTO :hv_custname
FROM customer
WHERE custnum = :hv_this_customer;
...
strcpy(new_name, hv_custname);
The host variable hv_custname is preceded by a colon (:) in the SQL statement. In
the strcpy function call, hv_custname is not preceded by a colon.
EXEC SQL SELECT custname
INTO :HV-CUSTNAME
FROM customer
WHERE custnum = :HV-THIS-CUSTOMER
END-EXEC.
...
MOVE HV-CUSTNAME TO NEW-NAME.
The host variable HV-CUSTNAME is preceded by a colon (:) in the SQL statement. In
the MOVE statement, HV-CUSTNAME is not preceded by a colon.
See Section 3, Host Variables in C/C++ Programs, and Section 4, Host Variables in
COBOL Programs.
Using DML Statements to Manipulate Data
Use simple DML statements in your application program to retrieve and modify data in
an SQL/MX database.
You can first test DML statements by using MXCI, the SQL/MX conversational
interface. The SQL statements you enter within MXCI do not include the use of host
variables, and SELECT results returned by MXCI are presented to you in the form of a
result table. However, despite these differences, you can verify much of the coding of
an SQL statement before embedding the statement in your program.
COBOL
C
COBOL