AnyDAC
ContentsIndexHome
PreviousUpNext
TADSQLiteCollation Class

The class implementing custom SQLite collation.

Group
Class Hierarchy
uADPhysSQLite_TADSQLiteCollationuADPhysSQLite_TADSQLiteCollationuADPhysSQLite_TADSQLiteCollation
File

uADPhysSQLite

Links

Use the TADSQLiteCollation to register a custom SQLite collation. A registered collation then may be used in any place in SQL command, where a collation may be specified. For example: 

 

SELECT * FROM "Employees" ORDER BY LastName COLLATE UTF16NoCase

 

Each collation must have an unique name specified by CollationName. And one of the three collation kinds specified as the additional properties:

  • CollationKind = scCompareString. The collation will use Win32 / Win64 API CompareStringW. To setup it properties use the Locale and Flags properties.
  • CollationKind = scCustomUTF8. To compare strings application should use OnCompare event, which will receive strings in UTF8 encoding.
  • CollationKind = scCustomUTF16. Similar to scCustomUTF8, but strings will be in UTF16 encoding.

After setting up the collation it must be activated using Active property. To use a collation in a SQLite connection, application must activate the collation before opening a database connection.

TADSQLiteCollation = class(TADSQLiteService);
ADSQLiteCollation1.DriverLink := ADPhysSQLiteDriverLink1;
ADSQLiteCollation1.CollationName := 'UTF16NoCase';
ADSQLiteCollation1.CollationKind := scCompareString;
ADSQLiteCollation1.Flags := [sfIgnoreCase];
ADSQLiteCollation1.Active := True;

See <AnyDAC>\Samples\DBMS Specific\SQLite\UserCollation

What do you think about this topic? Send feedback!