Indicator variables associated with host variables are used to indicate the presence or absence of NULL values in the data. To avoid having to designate one of the valid values for each data type to represent the NULL value, for example, zero or blanks, a separate indicator variable is associated with each host variable. The indicator variable must be checked first. If the indicator variable contains -1, the value of the associated host variable is NULL. In this case, the value present in the host variable itself is undefined. If the indicator variable contains anything other than -1, the value of the associated host variable is not NULL; it is the value in the host variable itself.
An indicator variable must be associated with a host variable if the host variable will become NULL. An error message is issued if an indicator variable is not associated with a host variable and SQL attempts to assign a NULL value to the host variable. It is recommended that you always use indicator variables to avoid the possibility of encountering that error.
Provision is made in the CA Datacom/DB SQL Preprocessor for recognizing indicator variables.
An indicator variable must be defined as a SMALLINT data type. The indicator variable can be defined anywhere a host variable can be defined.
An indicator variable is associated with a host variable by the form:
:host-variable:indicator-variable
In the previous format:
The rules for forming host variable names in an SQL statement apply equally to the host-variable and the indicator-variable. Both the host variable name and the indicator variable name can be qualified names. For more information on forming host variable names, see Host Variables.
|
Copyright © 2014 CA.
All rights reserved.
|
|