Host Variables

A host variable is a variable that is referenced in an SQL statement embedded in an application program. You use host variables to:
idmscu19
A host variable is a variable that is referenced in an SQL statement embedded in an application program. You use host variables to:
  • Make data in the CA IDMS database available for processing by an application program
  • Make data from sources other than the database (for example, from a sequential file) available for processing by SQL statements
Host variables are not used in SQL statements submitted through the command facility.
An INTO clause is required for SQL SELECT statements embedded in host programs.
Indicator Variables
An indicator variable is a host variable used to indicate whether the value in another host variable represents a null or truncated value. The use of indicator variables is optional. You can reference a host variable in an SQL statement with or without naming an associated indicator variable. However, if a SELECT or FETCH statement causes a null value to be assigned to a host variable without an associated indicator variable, CA IDMS returns an error.
Indicator Variable Values
When assigning a value to a host variable, CA IDMS sets the associated indicator variable as follows:
Indicator variable
Meaning
-1
The value assigned to the host variable was null. The contents of the host variable are unchanged.
0
The host variable contains a non-null value that has not been truncated.
1 or greater
The host variable contains a truncated value. The value in the indicator variable is the length in bytes of the original untruncated value.
Declaring Host Variables
Before you execute an SQL statement that references a host variable, you must declare the variable to CA IDMS:
  • Explicitly
    in an SQL declaration section
  • Implicitly
    with an INCLUDE statement
A single application program can include both explicit and implicit host variable declarations.
For more information about using the INCLUDE statement to declare host variables, see INCLUDE.
SQL Declaration Section
In an explicit host variable declaration, you specify the name and data type of the variable. Depending on the program language, additional information about the variable may also be required (for example, the COBOL level number).
Host variable names must conform to language-specific rules for forming variable names.
For more information about language-specific instructions for declaring host variables in an SQL declaration section, see Host Variables in an SQL Statement.