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-7
Using Corresponding SQL and COBOL Data Types
Table 4-2. Corresponding SQL, COBOL Host Variable Data Types, and
Translated COBOL Declarations for NUMERIC, DECIMAL, PIC, SMALLINT,
LARGEINT, and Date-Time Data Types (page1of2)
SQL Data Type
COBOL Host Variable Data
Type
Translated COBOL
Declaration
NUMERIC (1 to 4,s)
SIGNED
PIC[TURE] S9(4-s)V9(s)
COMP.
1
PIC[TURE]
S9(4-s)V9(s)
COMP.
1
NUMERIC (1 to 4,s)
UNSIGNED
PIC[TURE] 9(4-s)V9(s)
COMP.
1
PIC[TURE]
9(4-s)V9(s) COMP.
1
NUMERIC (5 to 9,s)
SIGNED
PIC[TURE] S9(9-s)V9(s)
COMP.
1
PIC[TURE]
S9(9-s)V9(s) COMP.
4
NUMERIC (5 to 9,s)
UNSIGNED
PIC[TURE] 9(9-s)V9(s)
COMP.
1
PIC[TURE]
9(9-s)V9(s) COMP.
1
NUMERIC (10 to 18,s)
SIGNED
PIC[TURE] S9(18-s)V9(s)
COMP.
1
PIC[TURE]
S9(18-s)V9(s)
COMP.
1
PIC[TURE] [S]9(l-
s)V9(s) COMP
Same as NUMERIC Same as NUMERIC
DEC[IMAL] (l,s)
SIGNED
PIC[TURE] S9(l-s)V9(s)
DISPLAY SIGN LEADING
SEPARATE.
PIC[TURE]
S9(l-s)V9(s)
DISPLAY SIGN
LEADING SEPARATE.
DEC[IMAL] (l,s)
UNSIGNED
PIC[TURE] 9(l-s)V9(s)
DISPLAY.
PIC[TURE]
9(l-s)V9(s)
DISPLAY.
PIC[TURE] [S]9(l-
s)V9(s)
Same as DECIMAL Same as DECIMAL
SMALLINT SIGNED PIC[TURE] S9(4) COMP.
1
PIC[TURE] S9(4)
COMP.
1
SMALLINT UNSIGNED PIC[TURE] 9(4) COMP.
1
PIC[TURE] 9(4)
COMP.
1
INT[EGER] SIGNED PIC[TURE] S9(9) COMP.
1
PIC[TURE] S9(9)
COMP.
1
INT[EGER] UNSIGNED PIC[TURE] 9(9) COMP.
1
PIC[TURE] 9(9)
COMP.
1
l A positive integer that represents the length.
s A positive integer that represents the scale of the number.
1 NonStop SQL/MX treats BINARY as COMP[UTATIONAL].
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.