This topic introduces rules regarding character string assignment.
The rules are as follows:
- When a character or graphic string is assigned to a column, the length
of the string value must not be greater than the length attribute of the column.
(Trailing blanks are normally included in the length of the string. However,
for string assignment, trailing blanks are not included in the length of the
string.)
- When a binary string is assigned to a column, the length of the string
value must not be greater than the length attribute of the column. (Hexadecimal
zeros are normally included in the length of the string. However, for string
assignment, hexadecimal zeros are not included in the length of the string.)
- When a MIXED character result column is assigned to a MIXED column, the
value of the MIXED character result column must be a valid MIXED character
string.
- When the value of a result column is assigned to a host
variable and the string value of the result column is longer than the length
attribute of the host variable, the string is truncated on the right by the
necessary number of characters. If this occurs, SQLWARN0 and SQLWARN1 (in
the SQL communication area (SQLCA)) are set to W.
- When the value of a result column is assigned to a fixed-length character
or graphic host variable or when the value of a host variable is assigned
to a fixed-length character or graphic result column and the length of the
string value is less than the length attribute of the target, the string is
padded on the right with the necessary number of blanks.
- When the value of a result column is assigned to a fixed-length binary
host variable or when the value of a host variable is assigned to a fixed-length
binary result column and the length of the string value is less than the length
attribute of the target, the string is padded on the right with the necessary
number of hexadecimal zeros.
- When a MIXED character result column is truncated because the length of
the host variable into which it was being assigned was less than the length
of the string, the shift-in character at the end of the string is preserved.
The result, therefore, is still a valid MIXED character string.