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 COBOL—523627-004
4-6
Using Corresponding SQL and COBOL Data Types
Table 4-2 lists the corresponding SQL data type, C host variable data type, and
translated COBOL declaration for the NUMERIC, DECIMAL, PIC, SMALLINT,
LARGEINT, and date-time data types. You can specify a COBOL host variable if it has
a corresponding SQL data type.
01 column-name.
03 LEN PIC S9(4) COMP.
03 VAL [char-set]
PIC X(l).
CHAR
[ACTER]
VARYING(l)
VARCHAR
[ACTER](l)
01 column-name.
03 LEN PIC S9(4) COMP.
03 VAL [char-set]
PIC X(l).
DATE DATE PIC[TURE] X(l).
2
TIME [(n)] TIME
[(time-
precision)]
PIC[TURE] X(l).
2
TIMESTAMP[(n)] TIMESTAMP[(
time-
precision)]
PIC[TURE] X(l).
2
INTERVAL [period1[(n)] |
SECOND [(n[,m])]] [TO
period2[(m)]]
INTERVAL
{start-
field TO
end-field |
single-
field}
PIC[TURE] X(l).
3
l A positive integer that represents the length.
1 KANJI and KSC5601 character sets can be used only with SQL/MP tables.
2 For DATE, the value of the length l is 10. For TIME(6), the value of the length l is 15. For TIMESTAMP(6),
the value of the length l is 26.
3 The INTERVAL data type has an extra character for a sign. The sign is included in the length l.
Table 4-1. COBOL Character Host Variables and Their SQL Data Type
Equivalents and COBOL Translations (page2of2)
COBOL Host Variable
SQL/MX
Equivalent
Data Type Translated COBOL Declaration