When you associate an indicator variable with an input variable, you must explicitly set the indicator variable, using the values in the following table as a guide.
Value |
Meaning |
---|---|
-1 |
Treat the corresponding input as a null value. |
0 |
Assign the value of the host variable to the column. |
You must supply host language code to test for a null input value and set the indicator variable to -1. This informs Client-Library of a null value. When you set the indicator variable to -1, null is used regardless of the host variable’s actual value.
The following example demonstrates associating an indicator variable with an input variable. The database royalty column will be set to a null value because R-INDIC is set to -1. Changing the value of R-INDIC changes the value of royalty.
exec sql begin declare section end-exec
01 R-INDIC PIC S9(4) COMP.
01 R-VAR PIC X(10).
exec sql end declare section end-exec.
MOVE -1 TO R-INDIC.
exec sql update titles
set royalty = :R-VAR :R-INDIC
where pub_id="0736" end-exec.