When you associate an indicator variable with an output or result variable, Client-Library automatically sets it to one of the following values in Table 4-1:
Value |
Meaning |
---|---|
-1 |
The corresponding database column in Adaptive Server contains a null value. |
0 |
A non-null value was assigned to the host variable. |
>0 |
An overflow occurred while data was being converted for the host variable. The host variable contains truncated data. The positive number represents the length, in bytes, of the value before it was truncated. |
The following example demonstrates associating the INDIC-V indicator variable with the PUB-NAME result variable:
exec sql begin declare section end-exec
01 INDIC-V PIC S9(4) COMP.
01 PUB-ID PIC X(4).
01 PUB-NAME PIC X(20).
exec sql end declare section end-exec
exec sql select pub_name into :PUB-NAME :INDIC-V
from publishers where pub_id = :PUB-ID
end-exec.
if INDIC-V = -1
display "No Publisher name"
else
display "Publisher Name is: " PUB-NAME.