SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
I-11
Indicator Variables and Indicator Parameters
Guardian names in the INDEXES table are fully qualified and use uppercase
characters. The Guardian security vector (column 13) is stored as uppercase
characters.
Indicator Variables and Indicator Parameters
In a host program, a variable called an indicator variable is associated with
each SQL data item that can contain a null value. The value of the indicator variable
tells whether the corresponding data item is null (indicator is less than 0) or contains an
actual value (indicator is 0).
Each indicator variable is a two-byte integer variable declared in the program. If you
use INVOKE to generate record descriptions, INVOKE automatically includes an
indicator variable for each item in the record that allows null values.
The INSERT, UPDATE, and SELECT statements use indicator variables. To send a
null value to SQL for insertion, update, or comparison, you assign a value less than 0
to the indicator variable. To return a null value to your program, SQL sets the
appropriate indicator variable to -1; to return a nonnull value, SQL sets the indicator
variable to 0. (For INSERT or UPDATE, you can use the keyword NULL instead of an
indicator variable.)
Indicator parameters serve the same purpose as indicator variables, but you use them
to specify null input parameters in dynamic SQL or SQLCI statements. An indicator
parameter appears following the associated input variable but separated by the key
word INDICATOR. For example, this statement pass a negative indicator parameter (I)
to SQL to indicate that the parameter P contains a null value:
SET PARAM ?I -1
INSERT INTO =EMPLOYEE VALUES (1000, ?P INDICATOR ?I);
For more information about using indicator variables or indicator parameters in host
programs, see the SQL/MP programming manual for your host language.