You can declare character data types as host variables with a fixed maximum length by explicitly supplying the length of the character array, or by declaring the host variable with an initial value, for example:
EXEC SQL BEGIN DECLARE SECTION; char var1; char var2 = "Initialized string"; EXEC SQL END DECLARE SECTION;
In the example, two host variables are declared, each with a maximum length of 18 bytes.
Host variables declared as single-byte characters with no explicit length or initial values (for example, char var) are treated as 1-byte integer data types.
Here is how C character data types are mapped to or from the Microsoft® SQL Server™ 2000 char, varchar, or text data types.
|Mapped data types||When converted|
|From C character to SQL Server char, varchar, or text||Data is copied and truncated or padded with blanks if the SQL Server table receiving the columns is set to a fixed length.|
|To C character from SQL Server char, varchar, or text||Data is copied and, if necessary, truncated to the length of the receiving field and is terminated with a NULL. If data is truncated, the SQLWARN1 field of the SQLCA data structure is set.|