informix
Informix Guide to GLS Functionality
Informix ESQL/C Features

Using Enhanced ESQL Library Functions

Informix SQL API products support locale-specific enhancements to the ESQL/C library functions. These ESQL/C 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 are as follows:

These functions support the following extensions to format era-based DATE values:

This section describes locale-specific behavior of the ESQL DATE-format functions. For information about the ESQL/C DATE-format functions, see the Informix ESQL/C Programmer's Manual.

GL_DATE Support

The value of the GL_DATE environment variables can affect the results that these ESQL/C 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

The ESQL/C DATE-format functions that support the extended era-based date syntax for the DBDATE environment variable are as follows:

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:

Important: Informix products treat any undefined characters in the alphabetic era specification as an error.

If you set DBDATE to a era-based date format (which 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

The ESQL/C DATE-format functions that support the extended-DATE format strings are as follows:

The following table shows the extended-format strings that these ESQL/C functions support for use with GLS locales. These extended-format strings format eras with 2-digit year offsets.

Era Year Format Era Used
Full era year: full name of the base year (period) followed by a 2-digit year offset Same as GL_DATE end-user format of "%EC%02.2Ey" eyy The era that the client locale (which CLIENT_LOCALE indicates) defines
Abbreviated era year: abbreviated name of the base year (period) followed by a 2-digit year offset Same as GL_DATE end-user format of "%Eg%02.2Ey" gyy The era that the client locale (which CLIENT_LOCALE indicates) defines

The following table shows some sample extended-format strings for era-based dates. These examples assume that the client locale is Japanese SJIS (ja_jp.sjis).

Description Sample Format October 5, 1990 prints as:
Abbreviated era year gyymmdd
gyy.mm.dd
H021005
H02.10.05
Full era year eyymmdd
eyy-mm-dd
eyyB1B2mmB1B2ddB1B2
A1A2021005
A
1A202-10-05
A
1A202B1B210B1B205B1B2

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:

Precedence for Date End-User Formats

The ESQL/C 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 format from the default locale: %m %d %iY

For more information on the precedence of DBDATE, GL_DATE, and CLIENT_LOCALE, refer to Date and Time Precedence.

Tip: Informix products support DBDATE for compatibility with earlier products. Informix recommends that you use the GL_DATE environment variable for new client applications.

DATETIME-Format Functions

The ESQL DATETIME-format functions are as follows:

These functions support the following extensions to format era-based DATETIME values:

This section describes locale-specific behavior of the ESQL/C DATETIME-format functions. For general information about the ESQL/C DATETIME-format functions, see the Informix ESQL/C 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/C DATETIME-format functions support the extended era-based date and time format strings for the DBTIME environment variable. 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.

Tip: Informix products support DBTIME for compatibility with earlier products. Informix recommends that you use the GL_DATETIME environment variable for new applications.

If you set DBTIME to a era-based DATETIME format (which 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/C DATETIME-format functions support.

Format Description December 27, 1991 Printed
%y %m %dc1 Taiwanese Ming Guo date 80 12 27
%Y %m %dc1 Taiwanese Ming Guo date 0080 12 27
%y %m %dj1 Japanese era with abbreviated era symbols H03 12 27
%Y %m %dj1 Japanese era with abbreviated era symbols H0003 12 27
%y %m %dj2 Japanese era with full era symbols A1A2B1B203 12 27
%Y %m %dj2 Japanese era with full era symbols A1A2B1B20003 12 27

In addition to the formats in the preceding table, these ESQL/C DATETIME-format functions support the GLS date and time specifiers. For a list of these specifiers, see GL_DATE and GL_DATETIME.

Precedence for DATETIME End-User Formats

The ESQL/C 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 Date and Time Precedence.

Numeric-Format Functions

The ESQL/C numeric-format functions are as follows:

These functions support the following extensions to format numeric values:

This section describes locale-specific behavior of the ESQL/C numeric-format functions. For general information about the ESQL/C numeric-format functions, see the Informix ESQL/C Programmer's Manual.

Tip: For a list of errors that these ESQL/C numeric-format functions might return, see GLS-Specific Error Messages.

Support for Multibyte Characters

The ESQL/C numeric-format functions 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/C 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 (if the client code set contains the A1A2 character):

Locale-Specific Numeric Formatting

The ESQL/C numeric-format functions 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.

Formatting Character Function
Dollar sign ($) Currency symbol
Comma (,) Thousands separator
Period (.) Decimal separator

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. For information about the locale-specific behavior of DBMONEY, see DBMONEY Extensions.

  3. The symbols that the appropriate locale category of the client locale (if CLIENT_LOCALE is set) specifies
  4. 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.

    For more information on the use of the $ and @ formatting characters, see Currency-Symbol Formatting. For more information on the MONETARY and NUMERIC locale categories, see Locale Categories.

  5. 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 logical MONEY value of 78941.00 (if DBMONEY is not set).

Format String Client Locale Formatted Value
$***,***.&& Default locale (en_us.8859-1) $*78,941.00
German locale (de_de.8859-1) DM*78.941,00
Spanish locale (es_es.8859-1) Pts*78.941,00

Currency-Symbol Formatting

The ESQL/C numeric-format functions support all formatting characters that the Informix ESQL/C Programmer's Manual describes. In addition, you can use the following formatting characters to indicate the placement of a currency symbol in the formatted output.

Formatting Character Function
$ This character is replaced by the precede-currency symbol if the locale defines one. The MONETARY category of the locale defines the precede-currency symbol, which is the symbol that appears before a monetary value. When you group several dollar signs in a row, a single currency symbol floats to the right-most position that it can occupy without interfering with the number.
@ This character is replaced by the succeed-currency symbol if the locale defines one. The MONETARY category of the locale defines the succeed-currency symbol, which is the symbol that appears after a monetary value.

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.

Format String Client Locale Formatted Result
$***,*** Default locale (en_us.8859-1) German locale (de_de.8859-1) French locale (fr_fr.8859-1) $******1 DM******1 s******1
$***,***@ Default locale (en_us.8859-1) German locale (de_de.8859-1) French locale (fr_fr.8859-1) $******1s DM******1s s******1FF
$$,$$$.$$ Default locale (en_us.8859-1) German locale (de_de.8859-1) French locale (fr_fr.8859-1) ssss$1.00 ssssDM1,00 sssss1FF
***,***@ Default locale (en_us.8859-1) German locale (de_de.8859-1) French locale (fr_fr.8859-1) ******1s ******1s ******1FF
@***,*** Default locale (en_us.8859-1) German locale (de_de.8859-1) French locale (fr_fr.8859-1) s******1 s******1 FF******1

In the preceding table, the character s represents a blank or space, FF is the French currency symbol for French francs, and DM is the German currency symbol for deutsche marks.

The DBMONEY environment variable can also set the precede-currency symbol and the succeed-currency symbol. The syntax diagram in DBMONEY 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 if your client code set supports them. For example, the following table shows how multibyte characters appear in sample output.

Format String Number to Format DBMONEY Output
"$$,$$$.$$" 1234 '$'. $1,234.00
"$$,$$$.$$" 1234 DM, DM1.234,00
"$$,$$$.$$" 1234 A1A2. A1A21,234.00
"$$,$$$.$$" 1234 .A1A2 s1,234.00
"&&,&&&.&&@" 1234 .A1A2 s1,234.00A1A2
"$&&,&&&.&&@" 1234 A1A2. A1A2s1,234.00
"$&&,&&&.&&@" 1234 .A1A2 s1,234.00A1A2
"@&&,&&&.&&" 1234 .A1A2 A1A2s1,234.00

In the preceding table, the character s represents a blank or space.

String Functions

The following ESQL/C string functions 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. If the client locale specifies a multibyte code set, these functions can operate on multibyte strings.

Important: With multibyte character strings, a shifted string might occupy more memory after a shift operation than before. You must ensure that the buffer you pass to these ESQL/C shift functions is large enough to accommodate this expansion.

GLS-Specific Error Messages

The following ESQL/C functions might generate GLS-specific error messages:

For more information on GLS-specific error messages, use the finderr utility on UNIX, the Find Error utility on Windows NT, or the Informix Error Messages in Answers OnLine.


Informix Guide to GLS Functionality, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved