Using Indicator Variables to Exchange NULL Values
Indicator variables in ESQL work much like indicator variables in Progress/SQL. When the indicator variable is set to -1, the SQL value of the host language variable specification is NULL. When the indicator variable is set to 0, the SQL value of the host language variable specification is in the host language variable itself.
To assign (or input) a NULL value to the column or parameter marker corresponding to a host language variable, set the indicator variable to -1 before executing the statement that references it. Similarly, when you retrieve a NULL column value into a host language variable, ESQL sets the corresponding indicator variable to -1. If you provide an indicator variable, check the indicator variable value to determine what value has actually been returned. For NULL SQL values, whether input or output, the value of the host language variable is meaningless.
If you try to retrieve a NULL value to a host language variable without a corresponding indicator variable, ESQL returns an error with SQLCODE set to -43, or SQLSTATE set to 22 002.
To assign any input value other than NULL, set the host language variable to the value you want to assign and set any corresponding indicator variable to 0. To check for any output value other than NULL, first check to see that the indicator value is 0 before checking the host language variable for a non-NULL value.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |