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-10
Using Host Variables in a COBOL Program
{OF | IN} record-name
is an optional clause that specifies a level 01 item. The variable-name or
indicator_variable must be qualified by the record or group name only if the
host variable name or indicator variable name is not unique within the program.
This clause is an SQL/MX extension.
INDICATOR
is a keyword that can precede indicator_variable.
indicator_variable
is an indicator variable of exact numeric data type. You must declare the indicator
field as type PIC S9(4) COMP in COBOL. You must precede
indicator_variable with a colon (:) in an SQL statement. You must declare
an indicator variable along with its corresponding host variable within an SQL
Declare Section.
If data returned in the host variable is null, the indicator variable is less than zero. If
character data returned is truncated, the indicator variable is set to the length of
the string in the database. Otherwise, the value of the indicator variable is zero. To
insert null into the database, set the indicator variable to a value less than zero.
Using Host Variables in a COBOL Program
As a COBOL programmer, you need to know how to declare and use host variables to
retrieve and insert data with these SQL data types:
Fixed-Length Character Data on page 4-11
Variable-Length Character Data on page 4-12
Numeric Data on page 4-12
Date-Time and Interval Data on page 4-13
Character Set Data
These guidelines apply for NonStop SQL/MX Release 1.8 and NonStop SQL/MX
Release 2.x character sets:
ISO88591 character set: An SQL/MX Release 1.8 application can be run under
SQL/MX Release 2.x without application recompilation, if the application contains
ISO88591 character data only.
KANJI and KSC5601 character set: If KANJI or KSC5601 character set host
variables are contained in the application, the application must be carefully
rewritten and recompiled. KANJI and KSC5601 host variables in C applications are
translated as single-byte arrays in SQL/MX Release 1.8 and as double-byte arrays
in SQL/MX Release 2.x. If the application is not rewritten, SQL errors might be
emitted, corruption of data might occur, and the application might crash.