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.

About this task

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:

  • THRU phrase in a condition-name VALUE clause
  • literal-3 THRU literal-4 phrase in the EVALUATE statement
  • literal-1 THRU literal-2 phrase in the ALPHABET clause
  • Ordinal positions of characters specified in the SYMBOLIC CHARACTERS clause
  • THRU phrase in the CLASS clause

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.