/**
Installs user defined collations.

At the moment 5 user defined collations with the following names are installed:
- CompareC0 - 16-bit strings collated comaprison at level 0;
- CompareC1 - 16-bit strings collated comaprison at level 1;
- CompareC2 - 16-bit strings collated comaprison at level 2;
- CompareC3 - 16-bit strings collated comaprison at level 3;
- CompareF  - 16-bit strings folded comaprison;

These user defined collations can be used in the following cases:

- as column constraint in "CREATE TABLE" SQL statements. For example:
@code
  CREATE TABLE A(Col1 TEXT COLLATE CompareC1)
@endcode
In this case every time when Col1 values have to be compared, the SQL server will use CompareC1 collation.

- as column constraint in "CREATE INDEX" SQL statements. For example:
@code
  CREATE INDEX I ON A(Col1 COLLATE CompareC2)
@endcode
In this case SQL server will use CompareC2 collation to compare Col1 values when using the index.

- In "ORDER BY" clause of "SELECT" SQL statements. For example:
@code
  SELECT * FROM A ORDER BY Col1 COLLATE CompareC3
@endcode
In this case SQL server will use CompareC3 collation to compare Col1 values when building the result set.

@leave The function may leave with some database specific errors categorised as ESqlDbError.

@panic SqlDb 2 In _DEBUG mode. iDbHandle is NULL.
*/
void TSqlCollationUtil::InstallCollationsL()
	{
	__ASSERT_DEBUG(iDbHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));
	(void)sqlite3SymbianLastOsError();//clear last OS error
	//Register user defined collations
	for(TInt i=0;i<KCollationMethodCount;++i)
		{
		TInt err = sqlite3_create_collation16(iDbHandle, reinterpret_cast <const char*> (KCollationMethodName[i]), 
											  SQLITE_UTF16 | SQLITE_UTF16_ALIGNED, 0, KCollationMethodPtr[i]);
		__SQLLEAVE_IF_ERROR(::Sql2OsErrCode(err, sqlite3SymbianLastOsError()));
		}
	}
Exemple #2
0
__declspec(dllexport) int WINAPI sqlite3_create_collation16_interop(sqlite3* db, const void *zName, int eTextRep, void* pvUser, SQLITECOLLATION func, void **ppCookie)
{
  int n;
  SQLITECOLLATION *p = (SQLITECOLLATION *)malloc(sizeof(SQLITECOLLATION));
  
  p[0] = func;

  *ppCookie = 0;

  n = sqlite3_create_collation16(db, (const char *)zName, eTextRep, p, sqlite3_interop_collationfunc);
  if (n != 0)
    free(p);
  else
    *ppCookie = p;

  return n;
}