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

Handling MONEY Columns

The MONEY data type stores currency amounts. This data type stores fixed-point decimal numbers up to a maximum of 32 significant digits. You can specify MONEY columns in data definition statements such as CREATE TABLE and ALTER TABLE.

The choice of locale affects monetary data in the following ways:

The locale defines the default scale and currency notation in the MONETARY category of the locale file. For information on the MONETARY category of the locale file, see "The MONETARY Category".

Default Values for the Scale Parameter

Define a MONEY column with the following syntax:

Internally, the database server stores MONEY values as DECIMAL values. The precision parameter defines the total number of significant digits, and the scale parameter defines the total number of digits to the right of the decimal separator. For example, if you define a column as MONEY(8,3), the column can contain a maximum of eight digits, and three of these digits are to the right of the decimal separator. A sample data value in the column might be 12345.678.

If you omit the scale parameter from the declaration of a MONEY column, the database server provides a scale that the locale defines. For the default locale (U.S. English), the database server uses a default scale of 2. It stores the data type MONEY(precision) in the same internal format as the data type DECIMAL(precision,2). For example, if you define a column as MONEY(10), the database server creates a column with the same format as the data type DECIMAL(10,2). A sample data value in the column might be 12345678.90.

For nondefault locales, if you omit the scale when you declare a MONEY column, the database server declares a column with the same internal format as DECIMAL data types with a locale-specific default scale. For example, if you define a column as MONEY(10), and the locale defines the default scale as 4, the database server stores the data type of the column in the same format as DECIMAL(10,4). A sample data value in the column might be 123456.7890.

For the complete syntax of the MONEY data type, see the Informix Guide to SQL: Syntax. For a complete description of the MONEY data type, see the Informix Guide to SQL: Reference.

Format of Currency Notation

Client applications format values in MONEY columns with the currency notation that the locale defines. This notation specifies the currency symbol, thousands separator, and decimal separator. (For more information on currency notation, see "Numeric and Monetary Formats".)

For the default locale, the currency symbol is a dollar sign ($), the thousands separator is a comma (,), and the decimal separator is a period (.). For nondefault locales, the locale defines the appropriate culture-specific currency notation for monetary values. You can also use the DBMONEY environment variable to customize the currency symbol and decimal separator for monetary values. For more information, see "Customizing Monetary Values".




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