Numeric and List Parameters

Previous
Previous
Next
Next

This section contains the following topics:

Numeric Formats

The database must know the number-formatting convention used in each session to interpret numeric strings correctly. For example, the database needs to know whether numbers are entered with a period or a comma as the decimal character (234.00 or 234,00). Similarly, applications must be able to display numeric information in the format expected at the client site.

Examples of numeric formats are shown in Table: Examples of Numeric Formats.

Examples of Numeric Formats

Country Numeric Formats

Estonia

1 234 567,89

Germany

1.234.567,89

China

1,234,567.89

UK

1,234,567.89

US

1,234,567.89


Numeric formats are derived from the NLS_TERRITORY parameter setting, but they can be overridden by the NLS_NUMERIC_CHARACTERS parameter.

NLS_NUMERIC_CHARACTERS Parameter

The NLS_NUMERIC_CHARACTERS parameter specifies the group separator and decimal character. The group separator is the character that separates integer groups to show thousands and millions, for example. The group separator is the character returned by the G number format model. The decimal character separates the integer and decimal parts of a number. Setting the NLS_NUMERIC_CHARACTERS parameter overrides the default values derived from the setting of NLS_TERRITORY. The value can be any two valid numeric characters for the group separator and decimal character.

Any character can be the decimal character or group separator. The two characters specified must be single-byte, and the characters must be different from each other. The characters cannot be a numeric character or any of the following characters: plus sign (+), minus sign (-), less than sign (<), greater than sign (>). Either character can be a space.

To set the decimal character to a comma and the grouping separator to a period, specify the NLS_NUMERIC_CHARACTERS parameter as follows:

ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ",.";

SQL statements can include numbers represented as numeric or text literals. Numeric literals are not enclosed in quotation marks. They are part of the SQL language syntax, and always use a period as the decimal character and never contain a group separator. Text literals are enclosed in single quotation marks. They are implicitly or explicitly converted to numbers, if required, according to the current NLS settings.

The SELECT statement in Example: Setting NLS_NUMERIC_CHARACTERS=",." formats 4000 with the decimal character and group separator specified in the ALTER SESSION statement:

Setting NLS_NUMERIC_CHARACTERS=",."

ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ",.";
SELECT TO_CHAR(4000, '9G999D99') FROM DUAL;

The output from the example should be similar to the following:


TO_CHAR(4
---------
4.000,00