SQL/MP Programming Manual for COBOL

Host Variables
HP NonStop SQL/MP Programming Manual for COBOL529758-003
2-6
Specifying Host Variables in SQL Statements
Specifying Host Variables in SQL Statements
Use this syntax to specify a host variable in an SQL statement. You must precede the
host variable name with a colon (:). The colon causes the HP COBOL compiler to
handle the name as a host variable.
host-variable [ { OF | IN } record-name ]
specifies the name of the host variable as declared in the program. record-name
specifies a level 01 item. The host variable name must be qualified by the record
name or group item name only if the data item name is not unique in the program.
INDICATOR indicator-host-variable [ OF record-name ]
specifies an indicator variable to handle null values that might be returned to the
host variable or to insert null values into the database through the host variable. If
you omit the keyword INDICATOR before the variable name, an indicator is
assumed because host variable names are separated by commas.
Declare indicator-host-variable as a data item of type PIC S9(4) COMP.
For a value returned to the host variable from the database, SQL/MP sets the
indicator variable to -1 if the value is null or 0 if the value is not null.
To insert null values into a database, set the indicator variable to a value less than
0 for a null value or a value equal to or greater than 0 for a nonnull a value.
For more information about indicator values, see Using Indicator Variables for
Null Values on page 2-11.
TYPE AS
specifies that the host variable will have the specified date-time or INTERVAL data
type. A host variable that is to contain date or time values must be defined with a
character data type.
:host-variable [ { OF | IN } record-name ]
[[ INDICATOR ]:indicator-host-variable [ OF record-name ] ]
[ TYPE AS { DATETIME [start-date-time TO] end-date-time} ]
[ { } ]
[ { DATE } ]
[ { } ]
[ { TIME } ]
[ { } ]
[ { TIMESTAMP } ]
[ { } ]
[ { INTERVAL start-date-time } ]
[ { [ ( start-field-precision ) ] } ]
[ { [ TO end-date-time ] } ]