Controlling the collating sequence with a locale

Various operations such as comparisons, sorting, and merging use the collating sequence that is in effect for the program and data items. How you control the collating sequence depends on the code page in effect for the class of the data: alphabetic, alphanumeric, DBCS, or national.

A locale-based collating sequence for items that are class alphabetic, alphanumeric, or DBCS applies only when the COLLSEQ(LOCALE) compiler option is in effect, not when COLLSEQ(BIN) or COLLSEQ(EBCDIC) is in effect. Similarly, a locale-based collating sequence for class national items applies only when the NCOLLSEQ(LOCALE) compiler option is in effect, not when NCOLLSEQ(BIN) is in effect.

If the COLLSEQ(LOCALE) or NCOLLSEQ(LOCALE) compiler option is in effect, the compile-time locale is used for language elements that have syntax or semantic rules that are affected by locale-based collation order, such as:

If the COLLSEQ(LOCALE) compiler option is in effect, the collating sequence for alphanumeric keys in SORT and MERGE statements is always based on the runtime locale.