The basic operations of SQL are assignment and comparison.
Assignment operations are performed during the running of CALL, INSERT, UPDATE, FETCH, and SELECT INTO statements. Comparison operations are performed during the running of statements that include predicates and other language elements such as MAX, MIN, DISTINCT, GROUP BY, and ORDER BY.
The basic rule for both operations is that the data type of the operands involved must be compatible. The compatibility rule also applies to UNION, concatenation, and the VALUE, COALESCE, MIN, and MAX scalar functions.
The basic rule for string assignments is that the length of a string assigned to a column must not be greater than the length attribute of the column. (Trailing blanks are normally included in the length of the string. For string assignment, however, trailing blanks are not included in the length of the string.)
If the string contains mixed data, the assignment rules may require truncation within a sequence of double-byte codes. To prevent the loss of the shift-in character that ends the double-byte sequence, additional characters might be truncated from the end of the string, and a shift-in character added. In the truncated result, there is always an even number of bytes between each shift-out character and its matching shift-in character.
Character, DBCS-only, DBCS-open, and DBCS-either are not compatible with graphic types for assignment.