Function SetCollation() Foundation

Query current and/or set new active collation for current thread

SetCollation( [<nCollation>] ) --> nOldCollation
<nCollation> is the numeric identifier for the collation table to be selected. #define constants from the file COLLAT.CH must be used for this parameter.

If SetCollation() is called without the argument <nCollation>, the function returns the numeric identifier of the active collation table for the current thread.


The function SetCollation() activates a collation table for the current thread. A collation table defines weighing factors for sorting and comparing characters. Runtime functions such as ASort() and DbSort() depend on this setting. Also DbSeek() and index ordering with NTXDBE and CDXDBE use the active collation table for sorting of characters. The result of comparison operators such as <, <=, =, >=, > and <> depends also on the current collation table setting.

The collation table setting is thread local. When a new thread is created, it inherits the collation table setting of the thread in which it is created.

The default collation table of Xbase++ is set in DBESYS.PRG using the SET COLLATION command. DatabaseEngines also use the specific collation table setting to handle sorting and ordering of characters.

SetCollation() is introduced to provide a convenient way to get and set the collation table of a thread using a numeric identifier. #define constants are listed in the COLLAT.CH file that are used as collation identifiers. Valid collation #defines start with COLLAT_ followed by the specific name of the collation table.

a user-defined collation table can be defined using the function SetCollationTable().


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.