INFORMIX
Informix Guide to GLS Functionality
Chapter 7: General SQL API Features
Home Contents Index Master Index New Book

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.)
ESQL/C
Date Function
ESQL/COBOL
Date Routine

Figure 7-2
ESQL DATE-Format Functions That Support DBDATE Extensions

rdatestr()

ECO-DAT

rstrdate()

ECO-STR

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 (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.
ESQL/C
Date Function
ESQL/COBOL
Date Routine

Figure 7-3
ESQL DATE-Format Functions That Support Extended-Format Strings

rdefmtdate()

ECO-DEF

rfmtdate()

ECO-FMT

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
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 (that 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 (that CLIENT_LOCALE indicates) defines

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
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 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:

ALS
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
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"

yyj2

Japanese Imperial

Full era year: full name of the base year (period) followed by a 4-digit year offset

Same as GL_DATE end-user format of "%EC%04.4Ey"

yyyyj2

Japanese Imperial

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"

yyc1

yyj1

Taiwanese Ming Guo

Japanese Imperial

Abbreviated era year: abbreviated name of the base year (period) followed by a 4-digit year offset

Same as GL_DATE end-user format of "%Eg%04.4Ey"

yyyyc1

yyyyj1

Taiwanese Ming Guo

Japanese Imperial

The following table shows some sample ALS Version 5.0 extended-format strings for era-based dates.

Description Sample Format October 5, 1990
prints as:

Japanese era:

abbreviated era year, 2-digit year
abbreviated era year, 4-digit year

full era year, 2-digit year
full era year, 4-digit year

yymmddj1
yyyymmddj1

yymmddj2
yyyymmddj2

H021005
H00021005

A1A2021005
A
1A200021005

Taiwanese Ming Guo date:

with 2-digit year

with 4-digit year

yymmddc1
yy.mm.ddc1
yyA1A2mmA1A2ddA1A2

yyyymmddc1

791005
79.10.05
79A
1A210A1A205A1A2

00791005

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
Era Format Format Locale

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"

nnnnyy

Japanese

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"

nyy

Japanese

Day of the week, with symbols that the locale defines (Sunday through Saturday in Asian characters). Multibyte characters are printed if DB_LOCALE is set to another language.

ww

The following table shows some sample ALS Version 4.x extended-format strings for era-based dates.
Description Sample Format October 5, 1990
prints as:

Japanese era:

abbreviated era year

full era year

nyymmdd

nnnnyy mm dd
nnnnyymmdd (ww)

H021005

A1A202 10 05
A
1A2021005 (B1B2)

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".

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

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.

Tip: Informix products support DBTIME for backward compatibility with earlier products. Informix recommends the use of the GL_DATETIME environment variable for new applications.
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.

Format Description December 27, 1991 appears as:

%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 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.

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

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.

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. 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).
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 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.
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 rightmost 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, 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.

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. 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.
ESQL/C
String Function
ESQL/COBOL
String Routine

Figure 7-10
ESQL String Functions That Support Locale-Specific Shifted Characters

rdownshift()

ECO-DSH

rupshift()

ECO-USH

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.

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

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.




Informix Guide to GLS Functionality, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.