Name
NLSSORT
Synopsis
The NLSSORT function returns a string of bytes that can be used to sort a string value in accordance with language-specific rules. The string returned is of the RAW datatype. The syntax for invoking NLSSORT is as follows:
NLSSORT(string1, [, 'NLS_SORT=sort_sequence_name'])
Following is an example of how NLSSORT can be used to ensure that two string values are compared according to language rules:
IF NLSSORT(x, 'NLS_SORT=XFRENCH') > NLSSORT(y, 'NLS_SORT=XFRENCH') THEN...
In this case, the IF statement is testing to see whether the string x is “greater” than the string y. If a simple x > y comparison were used, the results would depend simply on whether the binary representation of x was greater than y. For some languages, the underlying binary representation does not correlate to the sort sequence. The RAW strings returned by NLSSORT allow you to compare two values in the appropriate way for the ordering of characters in the language being used.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access