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-8
Data Conversion
Data Conversion
NonStop SQL/MX performs the conversion between SQL and COBOL data types:
•
When a host variable serves as an input variable (supplies a value to the
database), NonStop SQL/MX automatically converts the value that the variable
contains to a compatible SQL data type and then uses the value in the SQL
operation.
•
When a host variable serves as an output variable (receives a value from a
database), NonStop SQL/MX converts the value to the data type of the host
variable.
NonStop SQL/MX supports conversion within numeric types and character types, but
not between numeric and character types.
LARGEINT PIC[TURE] S9(18) COMP.
1
PIC[TURE] S9(18)
COMP.
1
FLOAT (1 to 22 bits)
REAL
Not supported. Not supported.
FLOAT (23 to 54
bits)
DOUBLE PRECISION
Not supported. Not supported.
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
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 (page2of2)
SQL Data Type
COBOL Host Variable Data
Type
Translated COBOL
Declaration
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.