The schema is SYSIBM.
The COLLATION_KEY_BIT function returns a VARCHAR FOR BIT DATA string representing the collation key of the string-expression in the specified collation-name.
The results of COLLATION_KEY_BIT for two strings can be binary compared to determine their order within the specified collation-name. For the comparison to be meaningful, the results used must be from the same collation-name.
String Argument Data Type | Result Data Type Length |
---|---|
CHAR(n) or VARCHAR(n) | Minimum of 12n bytes and 32 672 bytes |
GRAPHIC(n) or VARGRAPHIC(n) | Minimum of 12n bytes and 32 672 bytes |
Regardless of whether length is specified or not, if the length of the collation key is longer than the length of the result data type, an error is returned (SQLSTATE 42815). The actual result length of the collation key is approximately six times the length of string-expression after it has been converted to UTF-16.
If string-expression is an empty string, the result is a valid collation key that can have a nonzero length.
If any argument can be null, the result can be null; if any argument is null, the result is the null value.
Examples:
SELECT FIRSTNME, LASTNAME
FROM EMPLOYEE
ORDER BY COLLATION_KEY_BIT (LASTNAME, 'SYSTEM_923_DE')
SELECT E.WORKDEPT
FROM EMPLOYEE AS E INNER JOIN SALES AS S
ON COLLATION_KEY_BIT(E.LASTNAME, 'UCA400R1_LFR') =
COLLATION_KEY_BIT(S.SALES_PERSON, 'UCA400R1_LFR')
WHERE S.REGION = 'Quebec'