Using host variables with indicator variables

Declare host and indicator variables in a declare section before using them anywhere in an application program containing Embedded SQL statements. Declare indicator variables as 2-byte integers (short or CS_SMALLINT) in a declare section before using them.

Prefix indicator variables with a colon when using them in an Embedded SQL statement.

The syntax for associating an indicator variable with a host variable is:

:host_variable [[indicator] :indicator_variable]

The association between an indicator and host variable lasts only for the duration of a statement— that is, for the duration of one exec sql statement, or between open and close cursor statements. A value is assigned to the indicator variable at the same time a value is assigned to the host variable.

Adaptive Server sets the indicator variable only when you assign a value to the host variable. Therefore, you can declare an indicator variable once and reuse it with different host variables in different statements.

You can use indicator variables with output, result, and input variables. When used with output and result variables, Embedded SQL sets the variable to indicate the null status of the associated host variable. When used with input variables, you set the value of the indicator variable to show the null status of the input variable before submitting it to Adaptive Server.