SQL/MP Programming Manual for COBOL85

Host Variables
HP NonStop SQL/MP Programming Manual for COBOL85429326-004
2-2
Coding Host Variable Names
Coding Host Variable Names
Use COBOL naming conventions for host variable names. A COBOL name can
contain from 1 to 30 alphanumeric characters, including letters, digits, and hyphens (-).
The first or last letter cannot be a hyphen. Letters can be uppercase, lowercase, or a
combination of both. HP COBOL names must contain at least one letter or hyphen.
You must also avoid using names that conflict with these SQL structures:
SQLINALL internal structure
SQLCA, SQLSA, and SQLDA structures
To use a COBOL record description as a host variable, specify the record name as a
level 01 entry and use level numbers 01 to 49, 66, 77, and 88 for the host variables.
The individual data items, and not the record name, are the host variables. You must
use declarations compatible with the SQL data types as shown in Table 2-1. You must
also observe certain restrictions for the PICTURE clause; see Using the COBOL
PICTURE Clause on page 2-7 for more information.
Using Corresponding SQL and COBOL Data
Types
Table 2-1 shows the corresponding SQL and COBOL data types. You can specify a
COBOL data item as a host variable, if the COBOL data item has a corresponding SQL
data type.
Table 2-1. Corresponding SQL and COBOL Data Types (page 1 of 3)
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).
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.