SQL/MP Programming Manual for COBOL

Host Variables
HP NonStop SQL/MP Programming Manual for COBOL529758-003
2-3
Using Corresponding SQL and COBOL Data Types
Table 2-1. Corresponding SQL and COBOL Data Types (page 1 of 2)
SQL/MP Data Type COBOL Data Type
Fixed-Length Character Data Type
CHARACTER (l)
PIC X(l).
PIC X(l)
Fixed-Length Character Data Type With CHARACTER SET Clause
CHARACTER (l)
CHARACTER SET charset
PIC X(l)
CHARACTER SET charset
01 column-name
CHARACTER SET charset
PIC X(l).
Fixed-Length Character Data Type With NATIONAL CHARACTER Clause
NATIONAL CHARACTER (l) 01 column-name
CHARACTER SET def-charset
PIC X(l).
Variable-Length Character Data Type
VARCHAR(l)02 column-name.
03 LEN PIC S9(4) COMP.
03 VAL PIC X(l).
Variable-Length Character Data Type With CHARACTER SET Clause
VARCHAR(l) @@@
CHARACTER SET charset
01 column-name.
02 LEN PIC S9(4) COMP.
02 VAL CHARACTER SET charset
PIC X(l).
Variable-Length Character Data Type With NATIONAL CHARACTER Clause
NATIONAL CHARACTER
VARYING(l)
01 column-name.
02 LEN PIC S9(4) COMP.
02 VAL CHARACTER SET def-charset
PIC X(l).
Numeric Data Types
NUMERIC (1 to 4,s) SIGNED PIC S9(4-s)V9(s) COMP.
NUMERIC (1 to 4,s)
UNSIGNED
PIC 9(4-s)V9(s) COMP.
NUMERIC (5 to 9,s)SIGNED PIC S9(9-s)V9(s) COMP.
l is a positive integer that represents the length in characters.
charset is one of these character-set keywords: KANJI, KSC5601, ISO8859n, where n is 1 – 9,
or UNKNOWN (a single-byte unknown character set).
charset must be enclosed in double
quotation marks (").
def-charset is the default multibyte character set. def-charset is KANJI, unless it is
otherwise changed or set during system generation.
s is a positive integer that represents the scale of the number.
HP COBOL treats BINARY as COMPUTATIONAL (or COMP). Therefore, references to
COMPUTATIONAL (or COMP) also apply to BINARY.
The INTERVAL data type has an extra byte to store a sign. This extra byte can contain a blank, plus, or minus.
Indicator variables have the SQL data type SMALLINT SIGNED and the COBOL data type PIC S9(4) COMP.