The fixchar data type
The fixchar data type is the data type that holds character data that does not append a null terminator.
When an application reads a value from a CHAR column into a host
variable of type fixchar, pads
this value with trailing blanks up to the size of the host variable. does
not append any null character. The behavior is the same if an application
reads a value from a VARCHAR (or NVARCHAR) column into a host variable
of the fixchar data type.
Restriction: Do not use
the fixchar data type with VARCHAR, or NVARCHAR, data. With
a fixchar, even if the length of the data is shorter than the
size of the fixchar, the database server stores all n characters
of the fixchar, including any blanks at the end of the string.
Unless the blanks have significance, storing them defeats the space
savings that the VARCHAR data type provides.
Declare a fixchar host variable as an array with n components
(where n is the size of the column with values
that you want read). Use the following syntax to declare a host variable
of the fixchar data type:
EXEC SQL BEGIN DECLARE SECTION;
fixchar fch_name[n];
EXEC SQL END DECLARE SECTION;
Important: You
can copy a null-terminated C string into a fixchar variable
if space is available for the null character. However, this is not
good practice. When the database server inserts this value into a
column, it also inserts the null terminator. As a result, later searches
of the table might fail to find the value.