When two strings are compared, one of the strings is first converted, if necessary, to the coded character set of the other string.
Character conversion is necessary only if all of the following conditions are true:
If one string has an SBCS CCSID and the other is the same type of operand and has a mixed data CCSID, the SBCS data character string is converted. Otherwise, the string selected for conversion depends on the type of each operand. The following table shows which operand is selected for conversion, given the operand types.
First operand | Column value (second operand) | Derived value (second operand) | Special register (second operand) | Constant (second operand) | Host variable (second operand) |
---|---|---|---|---|---|
Column value | Second | Second | Second | Second | Second |
Derived Value | First | Second | Second | Second | Second |
Special Register | First | First | Second | Second | Second |
Constant | First | First | First | Second | Second |
Host Variable | First | First | First | First | Second |
A host variable containing data in a foreign encoding scheme is always effectively converted to the native encoding scheme before it is used in any operation. The previous rules are based on the assumption that this conversion has already occurred.
An error occurs if a character of the string cannot be converted or the CCSID Conversion Selection Table is used but does not contain any information about the pair of CCSIDs. A warning occurs if a character of the string is converted to the substitution character.