Indicator Variables
An indicator variable is a two‑byte integer variable associated with a host language variable in an embedded OpenSQL statement. Indicator variables enable the application to:
• Detect when a null has been retrieved into a host variable. (When used to detect or assign a null, indicator variables are referred to as null indicator variables.)
• Assign a null to a table column.
• Detect character string truncation (when retrieving from a table into a host variable).
Indicator variable must be declared to embedded OpenSQL in a declare section.
In an embedded OpenSQL statement, the indicator variable is specified immediately after the host variable, with a colon separating the two:
host_variable:indicator_variable
The optional keyword indicator can be used in the syntax:
host_variable indicator:indicator_variable
Indicator variables can be associated with host language variables that contain the value of a database column or a constant database expression. For example, the following statement associates null indicators with variables that contain values retrieved from table columns:
exec sql select ename, esal
into :name:name_null, :salary:sal_null
from employee;
Last modified date: 08/14/2024