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

Host Variables in COBOL Programs
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
4-2
COBOL Host Variable Data Types
02 CITY PIC X(14).
...
EXEC SQL INVOKE SALES.PARTS AS SALES-REC END-EXEC.
EXEC SQL END DECLARE SECTION END-EXEC.
COBOL Host Variable Data Types
You must explicitly declare all host variables used in SQL statements. A host variable
used in an SQL statement must be declared in an SQL Declare Section prior to the first
use of the host variable in an SQL statement. Only variables of the types recognized
by the 3GL preprocessor can appear within an SQL Declare Section.
To declare a COBOL host variable, specify one of these data types:
[char-set]PIC[TURE] X(l)
specifies the data type of a target host variable for a column of one of these SQL
data types:
CHAR[ACTER] [(l)]
PIC[TURE] X(l)
The length l corresponds to the length of the column value.
[char-set] can be specified as:
CHARACTER SET [IS] character-set-name
The optional [char-set] clause specifies the character set to be associated with
the host variable. character-set-name can be ISO88591 or UCS2 for SQL/MX
tables. character-set-name can be KANJI or KSC5601 for SQL/MP tables.
The default character set is ISO88591. Note that you can use host variables with
the KANJI or KSC5601 character set in an SQL/MX application only to access
KANJI or KSC5601 columns in an SQL/MP table.
[char-set]PIC[TURE][IS] {X[(length)]}
| nn column-name.
mm LEN PIC S9(4) COMP.
mm VAL [char-set] PIC X(l).
| DATE
| TIME [(n)]
| TIMESTAMP [(n)]
| INTERVAL [period1[(n)] | SECOND [(n[,m])]] [TO
period2[(m)]]
| PIC[TURE] [S]9(l-s)V9(s) COMP
| PIC[TURE] [S]9(p) COMP
| PIC[TURE] S9(l-s)V9(s) DISPLAY SIGN LEADING SEPARATE
| PIC[TURE] 9(l-s)V9(s) DISPLAY