Enhanced ESQL Library Functions
Informix SQL API products support locale-specific enhancements to the ESQL/C library functions and ESQL/COBOL routines. These ESQL library functions fall into the following categories:
In addition, this section describes the GLS-related error messages that these ESQL functions might produce.
DATE-Format Functions
The ESQL DATE-format functions in Figure 7-1 support the following extensions to format era-based DATE values:
This section describes locale-specific behavior of the ESQL DATE-format functions. For general information on the syntax and use of the ESQL/C DATE-format functions, see Chapter 6 of the INFORMIX-ESQL/C Programmer's Manual. For general information on the syntax and use of ESQL/COBOL DATE-format routines, see Chapter 3 of the INFORMIX-ESQL/COBOL Programmer's Manual.
GL_DATE Support
The value of the GL_DATE environment variables can affect the results that these ESQL DATE-format functions generate. The end-user format that GL_DATE specifies overrides date end-user formats that the client locale defines. For more information, see "Precedence for Date End-User Formats".
DBDATE Extensions
Figure 7-2 shows the ESQL DATE-format functions that support the extended era-based date syntax for the DBDATE environment variable. (For more information of the era-based date extensions, see the description of DBDATE on page 2-7.)
When you set DBDATE to one of the era-based formats, these functions use era-based dates to convert between date strings and internal DATE values. The following ESQL/C example shows a call to the rdatestr() library function:
If you set DBDATE to GY2MD/ and CLIENT_LOCALE to the Japanese SJIS locale (ja_jp.sjis), the preceding code fragment prints the following value for the date 08/18/1990:
If you set DBDATE to a era-based date format (that is specific to a Chinese or Japanese locale), make sure to set the CLIENT_LOCALE environment variable to a locale that supports era-based dates.
Extended DATE-Format Strings
Figure 7-3 shows the ESQL DATE-format functions that support the extended-DATE format strings.
Figure 7-4 shows the extended-format strings that these ESQL functions support for use with GLS locales.
Figure 7-4
Extended-Format Strings for GLS Locales
The extended-format strings in Figure 7-4 format eras with 2-digit year offsets. To obtain a 4-digit year offset, use the c1, j1, or j2 extended-format strings (see Figure 7-6).
Figure 7-5 shows some sample extended-format strings for era-based dates.
Figure 7-5
Sample Extended-Format Strings for GLS Locales
The examples in Figure 7-5 assume that the client locale is Japanese SJIS (ja_jp.sjis).
The following ESQL/C code fragment contains a call to the rdefmtdate() library function:
When the CLIENT_LOCALE specifies the Japanese SJIS (ja_jp.sjis) locale, the code fragment displays the following output:
Informix Version 9.1 products support additional extended-format strings for backward compatibility with Informix ALS products. Informix recommends that you use the extended-format strings that work with GLS locales (see Figure 7-4) in Version 9.1 client applications.
Figure 7-6 shows the extended-format strings that these ESQL functions support for backward compatibility with ALS Version 5.0 products.
Figure 7-6
Extended-Format Strings for ALS Version 5.x Compatibility
The following table shows some sample ALS Version 5.0 extended-format strings for era-based dates.
Figure 7-7 shows the extended-format strings that these ESQL functions support for backward compatibility with ALS Version 4.x products.
Figure 7-7
Extended-Format Strings for ALS 4.x Compatibility
The following table shows some sample ALS Version 4.x extended-format strings for era-based dates.
In addition to the era-based combinations in Figures 7-4 through Figure 7-7, the format string also supports the combinations that the INFORMIX-ESQL/C Programmer's Manual and the INFORMIX-ESQL/COBOL Programmer's Manual describe for these functions.
Precedence for Date End-User Formats
The ESQL DATE-format functions use the following precedence to determine the end-user format for values in DATE columns:
1. The end-user format that DBDATE specifies (if DBDATE is set)
2. The end-user format that GL_DATE specifies (if GL_DATE is set)
3. The date end-user format that the client locale specifies (if CLIENT_LOCALE is set)
4. The date end-user form from the default locale: %m %d %iY
For more information on the precedence of DBDATE, GL_DATE and CLIENT_LOCALE, refer to "Customizing Date and Time End-User Formats".
DATETIME-Format Functions
The ESQL DATETIME-format functions in Figure 7-8 support the following extensions to format era-based DATETIME values:
This section describes locale-specific behavior of the ESQL DATETIME-format functions. For general information on the syntax and use of the ESQL/C DATETIME-format functions, see Chapter 6 of the INFORMIX-ESQL/C Programmer's Manual. For general information on the syntax and use of ESQL/COBOL DATETIME-format routines, see Chapter 3 of the INFORMIX-ESQL/COBOL Programmer's Manual.
GL_DATETIME Support
The value of the GL_DATETIME environment variables can affect the results that these ESQL DATETIME-format functions generate. The end-user format that GL_DATETIME specifies overrides date and time formats that the client locale defines. For more information, see "Precedence for DATETIME End-User Formats".
DBTIME Support
The ESQL DATETIME-format functions in Figure 7-8 support the extended era-based date and time format strings for the DBTIME environment variable. (For more information on the era-based date and time extensions, see the description of DBTIME on page 2-20.)
When you set DBTIME to one of the era-based formats, these functions can use era-based dates and times to convert between literal DATETIME strings and internal DATETIME values.
If you set DBTIME to a era-based DATETIME format (that is specific to a Chinese or Japanese locale), make sure to set the CLIENT_LOCALE environment variable to a locale that supports era-based dates and times.
Extended DATETIME-Format Strings
The following table shows the extended-format strings that the ESQL functions in Figure 7-8 support.
In addition to the formats in the preceding table, these ESQL DATETIME-format functions support the GLS date and time specifiers. For a list of these specifiers, see the description of the GL_DATE and GL_DATETIME environment variables in Chapter 2, "GLS Environment Variables."
Precedence for DATETIME End-User Formats
The ESQL DATETIME-format functions use the following precedence to determine the end-user format of values in DATETIME columns:
1. The end-user format that DBTIME specifies (if DBTIME is set)
2. The end-user format that GL_DATETIME specifies (if GL_DATETIME is set)
3. The date and time end-user formats that the client locale specifies (if CLIENT_LOCALE is set)
4. The date and time end-user format from the default locale: %iY-%m-%d %H:%M:%S
For more information on the precedence of DBDATE, GL_DATE and CLIENT_LOCALE, refer to "Customizing Date and Time End-User Formats".
Numeric-Format Functions
The ESQL numeric-format functions in Figure 7-9 support the following extensions to format numeric values:
This section describes locale-specific behavior of the ESQL numeric-format functions. For general information on the syntax and use of the ESQL/C numeric-format functions, see Chapter 5 of the INFORMIX-ESQL/C Programmer's Manual. For general information on the syntax and use of ESQL/COBOL numeric-format routines, see Chapter 2 of the INFORMIX-ESQL/COBOL Programmer's Manual.
Support for Multibyte Characters
The ESQL numeric-format functions in Figure 7-9 support multibyte characters in their format strings as long as your client locale supports a multibyte code set that defines these characters. However, these ESQL functions and routines interpret multibyte characters as literal characters. You cannot use multibyte equivalents of the ASCII formatting characters.
For example, the following ESQL/C code fragment shows a call to the rfmtlong() function with the multibyte character A1A2 in the format string:
This code fragment generates the following output (as long as the client code set contains the A1A2 character):
Locale-Specific Numeric Formatting
The ESQL numeric-format functions in Figure 7-9 require a format string as an argument. This format string determines how the numeric-format function formats the numeric value. A format string consists of a series of formatting characters and the following currency notation.
Regardless of the client locale that you use, you must use the preceding ASCII symbols in the format string to identify where to place the currency symbol, decimal separator, and thousands separator. The numeric-format function uses the following precedence to translate these symbols to their locale-specific equivalents:
1. The symbols that DBMONEY indicates (if DBMONEY is set)
2. The symbols that the appropriate locale category of the client locale (if CLIENT_LOCALE is set) specifies
If the format string contains either a $ or @ formatting character, a numeric-format function assumes that the value is a monetary value and refers to the MONETARY category of the client locale. If these two symbols are not in the format string, a numeric-format function refers to the NUMERIC category of the client locale.
3. The actual symbol that appears in the format string ($, comma, or period)
In other words, these numeric-format functions replace the dollar sign in the format string with the currency symbol that DBMONEY specifies (if it is set) or with the currency symbol that the client locale specifies (if DBMONEY is not set). The same is true for the decimal separator and thousands separator.
For example, the following ESQL/C code fragment shows a call to the rfmtlong() function:
In the default, German, and Spanish locales, this code fragment produces the following results for the internal MONEY value of 78941.00 (if DBMONEY is not set).
Currency-Symbol Formatting
The ESQL numeric-format functions in Figure 7-9 support all formatting characters that Chapter 5 of the INFORMIX-ESQL/C Programmer's Manual and Chapter 2 of the INFORMIX-ESQL/COBOL Programmer's Manual describe. In addition, you can use the following formatting characters to indicate the placement of a currency symbol in the formatted output.
For more information, see "The MONETARY Category".
You can include both formatting characters in a format string. The locale defines whether the currency symbol appears before or after the monetary value, as follows:
The default locale defines the currency symbol as the precede-currency symbol, which appears as a dollar sign ($). In the default locale, the succeed-currency symbol appears as a blank. In the default, German, and French locales, the numeric-format functions produce the following results for the internal MONEY value of 1.00 .
In the preceding table, the character s represents a blank or space, the FF is the French currency symbol for French francs, and the DM is the German currency symbol for deutsche marks. For more information on locale-specific currency notation, see page 7-18.
The DBMONEY environment variable can also set the precede-currency symbol and the succeed-currency symbol. The syntax diagram for DBMONEY (see page 2-19) refers to these symbols as front and back, respectively. If set, DBMONEY takes precedence over the symbols that the locale defines.
DBMONEY Extensions
You can specify the currency symbol and decimal-separator symbol with the DBMONEY environment variable. These settings override any currency notation that the client locale specifies.
You can use multibyte characters for these symbols, as long as your client code set supports them. For example, the following table shows how multibyte characters appear in sample output.
Format String
|
Number to be Formatted
|
DBMONEY
|
Output
|
---|
"$$,$$$.$$"
| 1234
| '$'.
| $1,234.00
|
"$$,$$$.$$"
| 1234
| DM,
| DM1.234,00
|
"$$,$$$.$$"
| 1234
| A1A2.
| A 1A 21,234.00
|
"$$,$$$.$$"
| 1234
| .A1A2
| s1,234.00
|
"&&,&&&.&&@"
| 1234
| .A1A2
| s1,234.00A 1A 2
|
"$&&,&&&.&&@"
| 1234
| A1A2.
| A 1A 2s1,234.00
|
"$&&,&&&.&&@"
| 1234
| .A1A2
| s1,234.00A 1A 2
|
"@&&,&&&.&&"
| 1234
| .A1A2
| A 1A 2s1,234.00
|
In the preceding table, the character s represents a blank or space. For more information on DBMONEY, see page 2-19.
String Functions
Figure 7-10 shows the ESQL string functions that support locale-specific shifted characters.
These string functions use the information in the CTYPE category of the client locale to determine the shifted code points. (For more information on the CTYPE locale category, see page A-6.) If the client locale specifies a multibyte code set, these functions can operate on multibyte strings.
GLS-Specific Error Messages
The following ESQL functions might generate GLS-specific error messages:
For more information on GLS-specific error messages, refer to the Informix Error Messages manual.
|