In a client/server environment, the client application, database server, and one or more databases might reside on different computers. Figure 1 shows an example of database server connections between an ESQL/C client application and the acctng database through an Informix database server.
These computers might have different operating systems or different language support. To ensure that these three parts of the database application communicate locale information successfully, IBM Informix products support the following locales:
Figure 2 shows the client locale, database locale, and server locale that the example ESQL/C application (from Figure 1) establishes.
When you set the same or compatible GLS locales for each of these locales, your client application is not dependent on how the operating system of each computer implements language-specific features.
Sections that follow describe each of these locales in more detail.
The client locale specifies the language, territory, and code set that the client application uses to perform read and write (I/O) operations. In a client application, I/O operations include reading a keyboard entry or a file for data to be sent to the database and writing data that the database server retrieves from the database to the screen, a file, or a printer. In addition, an SQL API client uses the client locale for literal strings (end-user formats), embedded SQL (ESQL) statements, and host variables.
IBM Informix products use the CLIENT_LOCALE environment variable for the following purposes:
The C compiler and the operating system that you use might impose limitations on the ESQL/C program. For more information, see Generating Non-ASCII Filenames.
For more information, see Handling Non-ASCII Characters.
Code-set conversion prevents data corruption when these two code sets are different. For more information, see Performing Code-Set Conversion.
The database server uses CLIENT_LOCALE when it determines how to set the client-application information of the server-processing locale. For more information, see Establishing a Database Connection.
For more information, see Locating Message Files.
In the example connection that Figure 2 shows, if the client locale is German with the Windows Code Page 1252 (de_de.1252@euro), the German locale-specific information that the ESQL/C client application uses includes the following:
Di., 11. Feb 1997
EUR354.446,02
To determine the client locale, client applications use environment variables set on the client computer. To obtain the localized order and end-user formats of the client locale, a client application uses the following precedence:
Client applications that are based on IBM Informix Dynamic Server use the precedence of steps 2, 3, and 4 in the preceding list. You do not need to set the other environment variables for Dynamic Server client applications.
Support for DBDATE and DBTIME provides backward compatibility for client applications based on earlier versions of IBM Informix products. We recommend that you use GL_DATE and GL_DATETIME for new applications.
The database locale, which is set with the DB_LOCALE environment variable, specifies the language, territory, and code set that the database server needs to correctly interpret locale-sensitive data types (NCHAR and NVARCHAR) in a particular database. The code set specified in DB_LOCALE determines which characters are valid in any character column, as well as the names of database objects such as databases, tables, columns, and views. For more information, see Naming Database Objects.
The database locale also specifies the writing direction. Most languages are written left-to-right, but some are written right-to-left or top-to-bottom.
IBM Informix products use the DB_LOCALE environment variable for the following purposes:
Code-set conversion prevents data corruption when these two code sets are different. For more information, see Performing Code-Set Conversion.
The database server uses DB_LOCALE when it determines how to set the database information of the server-processing locale. For more information, see Establishing a Database Connection.
When the database server accesses columns of locale-sensitive data types, it uses the locale that DB_LOCALE specifies. For more information, see Verifying the Database Locale.
The database server stores a condensed version of the database locale in the systables system catalog table.
When the database server stores the database locale information directly in the system catalog, it permanently attaches the locale to the database. This information is used throughout the lifetime of the database. In this way, the database server can always determine the locale that it needs to interpret the locale-sensitive data correctly.
The SET COLLATION statement can specify the localized collation of a different locale to sort NCHAR and NVARCHAR data in the current session.
The condensed version of the database locale is stored in the following two rows of systables, which store the condensed locale name in the site column:
The database server uses the value of the DB_LOCALE environment variable that the client application sends. If you do not set DB_LOCALE on the client computer, however, the database server uses the value of DB_LOCALE on the server computer as the database locale.
In the connection shown in Figure 2, the database server references the database locale when the client application requests sorted information for an NCHAR column in the acctng database. If this locale is German with the Windows Code Page 1252 (de_de.1252), the database server uses a localized order that sorts accented characters, such as ö, after their unaccented counterparts. Thus, the string öff sorts after ord but before pre. For the syntax to set the database locale, see DB_LOCALE.
The server locale, which is set with the SERVER_LOCALE environment variable, specifies the language, territory, and code set that the database server uses to perform read and write (I/O) operations on the server computer (the computer on which the database server runs). These I/O operations include reading or writing the following files:
The database server does not use the server locale, however, to write files that are in an Informix proprietary format (database and table files). For a more detailed description of the files that the database server writes using the server locale, see Database Server Features.
The database server looks for product-specific message files in the message directory that is associated with the locale specified in SERVER_LOCALE. For more information, see Locating Message Files.
In the example connection that Figure 2 shows, the Informix database server uses the locale specified in SERVER_LOCALE to determine the code set to use when it writes a message-log file. For the syntax to set the server locale, see SERVER_LOCALE.