Sub topic 6
Language and Separators: NLS Settings and `nlsparam`
Assume you know basic SELECT, WHERE, and ORDER BY syntax and the NUMBER, VARCHAR2, and DATE data types. You should also be able to run SQL and understand the purpose of the DUAL table.
NLS means National Language Support. Oracle uses NLS settings to decide how it displays and reads language-sensitive values, such as month names, decimal separators, and currency symbols. These settings can come from the database, client, user, or current session.
That flexibility is useful for interactive applications. It is risky when SQL depends on the current session. Two users can run the same statement with different NLS settings and get different results, or one user's statement can fail.
Session settings versus explicit settings
You can inspect important session settings with this query:
SELECT parameter, value
FROM nls_session_parameters
WHERE parameter IN (
'NLS_DATE_FORMAT',
'NLS_DATE_LANGUAGE',
'NLS_NUMERIC_CHARACTERS',
'NLS_CURRENCY'
)
ORDER BY parameter;For example, NLS_NUMERIC_CHARACTERS might be ., for a period as the decimal separator and a comma for grouping. Another session might use ,.. NLS_DATE_LANGUAGE controls names such as JAN, JANUARY, and SAMSTAG.
A statement that relies on these settings has an unstated input. Prefer a format model and an nlsparam argument when the language or separators matter.
| Need | NLS setting or argument | Example |
|---|---|---|
| Month and day names | `NLS_DATE_LANGUAGE` | `NLS_DATE_LANGUAGE=ENGLISH` |
| Decimal and grouping marks | `NLS_NUMERIC_CHARACTERS` | `NLS_NUMERIC_CHARACTERS='.,'` |
| Currency symbol | `NLS_CURRENCY` | `NLS_CURRENCY='$'` |
Date language with `nlsparam`
A date format model describes the parts of a date. Text elements such as MON and MONTH depend on the date language.
SELECT TO_DATE(
'15-JAN-2026',
'DD-MON-YYYY',
'NLS_DATE_LANGUAGE=ENGLISH'
) AS parsed_date
FROM dual;The third argument is an nlsparam string. It overrides the relevant setting for this function call only. It does not change the session for other statements.
This makes the input contract clear: the string contains an English month abbreviation. Without the argument, the same statement could fail with ORA-01843: not a valid month in a session expecting another language.
The format model still matters. DD-MON-YYYY expects a day, a three-letter month, and a four-digit year in that order. NLS settings do not replace a matching format model.
Numeric separators and currency
Use G for the grouping separator and D for the decimal separator in a number format model. Supply the actual characters with NLS_NUMERIC_CHARACTERS.
SELECT TO_NUMBER(
'1.234,56',
'9G999D99',
'NLS_NUMERIC_CHARACTERS='',.'''
) AS amount
FROM dual;This returns the number 1234.56. In the nlsparam value, the first character is the grouping separator and the second is the decimal separator. Thus, ',.' would interpret 1,234.56 as the same number.
Currency formats can also use NLS settings. For example:
SELECT TO_CHAR(
1234.5,
'L9G999D00',
'NLS_NUMERIC_CHARACTERS='',.'' NLS_CURRENCY=''€'''
) AS displayed_amount
FROM dual;The L element inserts the local currency symbol. The explicit arguments make the output predictable for reports or exported files.
Common mistakes
- Supplying
NLS_DATE_LANGUAGE=ENGLISHbut using a numeric month, where language has no effect. - Reversing the two
NLS_NUMERIC_CHARACTERScharacters. - Using a format model that does not match the input order.
- Assuming
NLS_DATE_FORMATcontrols every conversion. An explicit format model takes precedence for that function call.
Exercise
Which nlsparam value parses 1.234,50 as the number 1234.50?
Show answer
Use NLS_NUMERIC_CHARACTERS='',.'' with a format model such as 9G999D99. The comma is the decimal separator, and the period is the grouping separator.