The string data type

The string data type is the Informix® ESQL/C data type that holds character data that is null terminated and does not contain trailing blanks.

However, if a string of blanks (that is, ‘ ’) is stored in a database field and selected into a host variable of the string data type, the result is a single blank character.

When an application reads a value from a CHAR column into a host variable of the string data type, it strips the value of any trailing blanks and appends a null terminator. The behavior is the same if an application reads a value from a VARCHAR column into a host variable of the string data type.

The one exception to this rule is that if the BLANK_STRINGS_NOT_NULL environment variable is set to 1 or any other value, like 0 or 2, the string host variable stores an empty string as a single blank followed by a null terminator. If this environment variable is not set, string host variables store an empty string as a null string.
EXEC SQL BEGIN DECLARE SECTION;
   string buffer[16];
EXEC SQL END DECLARE SECTION;
⋮

EXEC SQL select lname into :buffer from customer
   where customer_num = 102;
Declare the string data type with a length of [n + 1] (where n is the size of the column with values that you want read) to allow for the null terminator. In the preceding code fragment, the lname column in the customer table is 15 bytes so the buffer host variable is declared as 16 bytes. Use the following syntax to declare a host variable of the string data type:
EXEC SQL BEGIN DECLARE SECTION;
   string str_name[n + 1];
EXEC SQL END DECLARE SECTION;