5. Working with Embedded SQL : Host Language Variables in Embedded SQL : Indicator Variables : Indicator Variables and Character Data Retrieval
 
Share this page                  
Indicator Variables and Character Data Retrieval
When a character string is retrieved into a host language variable too small to hold the string, the data is truncated to fit. (If the data was retrieved from the database, the sqlwarn1 field of the SQLCA is set to 'W'.)
If the host language variable has an associated indicator variable, the indicator is set to the original length of the data. For example, the following statement sets the variable, char_ind, to 6 because it is attempting to retrieve a 6-character string into a 3-byte host language variable, char_3.
exec sql select 'abcdef' into :char_3:char_ind;
Note:  If a long varchar or long byte column is truncated into a host language variable, the indicator variable is set to 0. The maximum size of a long varchar or long byte column (two gigabytes) is too large a value to fit in an indicator variable.