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.

You must declare indicator variables as one of the following in a declare section:

PIC S9(4) COMP DISPLAY SIGN LEADING (and, optionally, SEPARATE) DISPLAY SIGN TRAILING (and, optionally, SEPARATE) COMP-3 COMP-4 COMP-5 BINARY

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 one exec sql statement.

ASE 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.

NoteYou can use indicator variables with output, result, and input variables.