Progress
Embedded SQL-92
Guide and Reference


Using Indicator Variables

Indicator variables are optional variables you can use to handle NULL values. Each indicator variable is associated with one host variable. Indicator variables should be of C Language data type LONG or database data type INTEGER (a 32-bit signed integer). The general format for using an indicator variable in an ESQL program is:

SYNTAX
:host_variable_name [ INDICATOR ] :indicator_variable_name 

NOTE: An indicator variable is always used with a host variable and you must prepend it with a colon ( : ) when you use it in an ESQL executable statement.

INDICATOR

The INDICATOR keyword is not required. Using the INDICATOR keyword clarifies the intent, especially if the names for the host variable and indicator variable do not follow a recognizable convention.

Table 3–2 lists the valid values for indicator variables and describes the meaning for each value.

Table 3–2: Indicator Variable Values and Their Meanings 
Value
Meaning of Indicator Variable Values
0
The associated host variable contains a non NULL value. If set by SQL in a fetch operation, 0 also indicates that the value in the host variable has not been truncated.
- 1
The returned value in an output operation is NULL and there is no value in the associated host variable. The value of the associated host variable for an UPDATE or INSERT operation is NULL.
> 0
The host variable size was too small to contain the returned value in an output operation, and the returned value in the host variable has been truncated. The indicator variable itself contains the > 0 length of the returned value before it was truncated. Only CHAR/VARCHAR data is truncated. For other data types, no data will be returned when the allocated area is not big enough.

This list provides a summary of how and when to use indicator variables:

For more information on indicator variables, see "Handling NULL Values in ESQL-92," and Handling Errors in ESQL-92."


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095