Handle locale-sensitive data (GLS)

the HCL OneDB™ database has a fixed locale per database. This locale, the database locale, is attached to the database at the time that the database is created. In any given database, all character data types (such as CHAR, NCHAR, VARCHAR, NVARCHAR, and TEXT) contain data in the code set that the database locale supports.

However, using the SQL statement SET COLLATION you can specify the collation order to use at runtime, which is independent of the locale used to store data in the database, and lasts for the duration of the session. You can use the mi_get_db_locale() function to determine which locale a user has set for the collation order in a session. If the user has not changed the collation, mi_get_db_locale() returns the default database locale. See the HCL OneDB Guide to SQL: Syntax for information about the SET COLLATION statement. See the HCL OneDB DataBlade® API Function Reference for information about the mi_get_db_locale() function.

An opaque data type can hold character data. The following support functions provide the ability to transfer opaque-type data between a client application and the database server:
  • The input and output support functions provide the ability to transfer the external representation of the opaque type.
  • The receive and send support functions provide the ability to transfer the internal representation of the opaque type.
However, the ability to transfer the data between client application and database server is not sufficient to support locale-sensitive data. It does not ensure that the data is correctly manipulated at each end. You must ensure that both sides of the connection handle the locale-sensitive data, as follows:
  • At the client side of the connection, the client application must handle the locale-sensitive data for opaque-type columns correctly.

    It must also have the CLIENT_LOCALE environment variable set correctly.

  • At the database server side of the connection, you must ensure that the appropriate support functions handle the locale-sensitive data.

    In addition, the DB_LOCALE and SERVER_LOCALE environment variables must be set correctly.

For more information about the CLIENT_LOCALE, DB_LOCALE, and SERVER_LOCALE environment variables, see the HCL OneDB GLS User's Guide.

To help you write support functions that handle locale-sensitive data, the HCL® OneDB GLS API is provided. The GLS API is a threadsafe library. This library contains C functions that allow your support functions to obtain locale-specific information from GLS locales, including:
  • Functions to manipulate locale-sensitive data in a portable fashion
  • Functions to handle single-byte and multibyte character access
  • Functions to manipulate other locale-sensitive data, such as the end-user formats of date, time, or monetary data

For an overview of the GLS API, see the HCL OneDB GLS User's Guide. For a description of the GLS API functions, see the HCL OneDB GLS User's Guide.