Search This Blog

Tuesday, July 8, 2025

How Do I Use NLS_TERRITORY in Oracle APEX

Introduction
Configuring NLS_TERRITORY in an Oracle APEX application ensures that dates, numbers, and currencies are formatted according to the user's regional standards. This setting defines territory-specific behaviors such as decimal separators, date formats, and first day of the week. Applying the appropriate NLS_TERRITORY improves clarity, user comfort, and localization accuracy in multi-regional applications.

 Using NLS_TERRITORY in Oracle APEX allows you to control how dates, numbers, currency symbols, and the first day of the week are displayed throughout your application, based on the user’s regional settings. This setting helps localize content for a specific territory, improving clarity and user experience in multi-language or international environments.

Here is how to use NLS_TERRITORY in detail within an Oracle APEX application:

  1. Understand the Role of NLS_TERRITORY
    NLS_TERRITORY determines:

    • Default date format

    • Decimal and group separators

    • Currency symbol and its placement

    • The first day of the week
      Each territory (e.g., US, FR, JP) comes with its own formatting conventions. For example:

    • US → mm/dd/yyyy, dot as decimal separator

    • FR → dd/mm/yyyy, comma as decimal separator

  2. Determine Where to Set It
    In Oracle APEX, you can set NLS_TERRITORY at the session level, giving you control for each user. This is typically done using a PL/SQL process at the application or page level.

  3. Create a Dynamic Session-Level Process
    In your application, go to Shared Components > Application Processes (or use a Before Header page process), and create a process like this:

    BEGIN
      IF :APP_LANGUAGE = 'fr' THEN
        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''FR''';
      ELSIF :APP_LANGUAGE = 'de' THEN
        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''GERMANY''';
      ELSE
        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''AMERICA''';
      END IF;
    END;
    

    This logic adjusts the territory based on the value of an application item like :APP_LANGUAGE or a user preference stored in a custom table.

  4. Allow Users to Choose Territory (Optional)
    To provide more flexibility:

    • Create an application item (e.g., G_TERRITORY) or a user preference table.

    • Populate a dropdown list of supported territories.

    • Use this value in your initialization PL/SQL to set NLS_TERRITORY.

  5. Test Format Behavior in the UI
    After setting NLS_TERRITORY, test how your application behaves:

    • Are date pickers displaying the correct format?

    • Are numbers shown with the correct separators?

    • Is currency formatting consistent?
      These will adjust automatically based on the session-level territory setting.

  6. Avoid Overriding Territory With Format Masks
    If you use explicit format masks in item properties (like DD-MON-YYYY), they override NLS_TERRITORY. To benefit from localization, prefer using generic or dynamic format settings unless strict formatting is required.

  7. Check Current Settings (Optional Debug)
    Use the following query to view current session NLS settings:

    SELECT * FROM NLS_SESSION_PARAMETERS WHERE PARAMETER = 'NLS_TERRITORY';
    

    This helps verify that the ALTER SESSION command is working as expected.

By using NLS_TERRITORY correctly in Oracle APEX, you can align the application experience with users’ regional expectations. It enhances clarity, reduces confusion with formats, and supports international usability, making your application both professional and globally accessible.

 

There are multiple ways to configure NLS_TERRITORY within Oracle APEX:

1. Setting NLS_TERRITORY at the Database Level

If you want the NLS_TERRITORY setting to apply globally across the entire database, you can modify it using the ALTER SESSION command.

ALTER SESSION SET NLS_TERRITORY = 'GERMANY';

This will update the session-specific settings for numeric formatting, date formats, and currency symbols according to German standards.

To check the current NLS_TERRITORY setting in the session, run:

SELECT VALUE FROM NLS_SESSION_PARAMETERS WHERE PARAMETER = 'NLS_TERRITORY';

2. Setting NLS_TERRITORY at the Application Level

Within Oracle APEX, you can define NLS_TERRITORY settings at the Application Level.

  1. Open App Builder and select your application.

  2. Navigate to Shared Components.

  3. Click Globalization Attributes.

  4. In the Date Format section, set the desired NLS_TERRITORY.

  5. Click Apply Changes.

This ensures that the selected country format applies throughout the application.


Dynamically Changing NLS_TERRITORY

3. Setting NLS_TERRITORY Per User

If you want different users to have different NLS_TERRITORY settings based on their location, you can modify it dynamically during login.

Create a Before Header Process on the Login Page to set the NLS_TERRITORY dynamically:

BEGIN

    IF APEX_UTIL.GET_SESSION_LANG = 'fr' THEN

        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''FRANCE''';

    ELSIF APEX_UTIL.GET_SESSION_LANG = 'de' THEN

        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''GERMANY''';

    ELSE

        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''UNITED STATES''';

    END IF;

END;

This ensures that users get the correct regional settings based on their language preference.


Using NLS_TERRITORY in SQL Queries

Once the NLS_TERRITORY setting is applied, it automatically affects how dates, numbers, and currency values are formatted in SQL queries.

Example 1: Formatting Dates Based on NLS_TERRITORY

SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY') FROM DUAL;

If NLS_TERRITORY is set to "GERMANY", this will return dates in the DD.MM.YYYY format instead of the US MM/DD/YYYY format.

Example 2: Formatting Numbers Based on NLS_TERRITORY

SELECT TO_CHAR(1234567.89, '999G999G999D99') FROM DUAL;

  • In "UNITED STATES", the output will be 1,234,567.89.

  • In "FRANCE", it will be 1 234 567,89.

  • In "GERMANY", it will be 1.234.567,89.

Example 3: Formatting Currency Based on NLS_TERRITORY

SELECT TO_CHAR(1000, 'L999G999D99') FROM DUAL;

  • In "UNITED STATES", the output will be $1,000.00.

  • In "UNITED KINGDOM", it will be £1,000.00.

  • In "JAPAN", it will be ¥1,000.


Applying NLS_TERRITORY in PL/SQL

If you need to apply NLS_TERRITORY settings inside a PL/SQL block, you can use:

BEGIN

    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''ITALY''';

END;

To get the current NLS_TERRITORY value inside a PL/SQL block:

DECLARE

    v_territory VARCHAR2(50);

BEGIN

    SELECT VALUE INTO v_territory 

    FROM NLS_SESSION_PARAMETERS 

    WHERE PARAMETER = 'NLS_TERRITORY';

    

    DBMS_OUTPUT.PUT_LINE('Current Territory: ' || v_territory);

END;


Best Practices for Using NLS_TERRITORY

  • Set NLS_TERRITORY early in a session to avoid inconsistencies in date or number formatting.

  • Use session-based settings instead of global database settings to allow different users to have different formats.

  • Test different locales by changing the NLS_TERRITORY value to ensure proper formatting.

  • Store user preferences in a database table and apply them dynamically when a user logs in.

Example:

DECLARE

    v_user_territory VARCHAR2(50);

BEGIN

    SELECT user_territory INTO v_user_territory FROM user_preferences WHERE user_id = :APP_USER;

    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''' || v_user_territory || '''';

END;

This way, users can choose their preferred settings, and the application will automatically adjust.


Implementing NLS_TERRITORY in Oracle APEX ensures that numeric, currency, and date formats are properly displayed according to a user’s regional preferences. By setting NLS_TERRITORY at the database, application, or session level, and using it in SQL and PL/SQL queries, you can build a globally adaptable application.

This enhances the user experience by allowing automatic formatting of data based on local conventions, ensuring better readability and usability for international users.


NLS_LANGUAGE and NLS_TERRITORY determine the default presentation of numbers, dates, and currencies.


Language Name

Language Code

NLS_LANGUAGE

NLS_TERRITORY

Afrikaans

af

ENGLISH

SOUTH AFRICA

Arabic

ar

ARABIC

UNITED ARAB EMIRATES

Arabic (Algeria)

ar-dz

ARABIC

ALGERIA

Arabic (Bahrain)

ar-bh

ARABIC

BAHRAIN

Arabic (Egypt)

ar-eg

EGYPTIAN

EGYPT

Arabic (Iraq)

ar-iq

ARABIC

IRAQ

Arabic (Jordan)

ar-jo

ARABIC

JORDAN

Arabic (Kuwait)

ar-kw

ARABIC

KUWAIT

Arabic (Lebanon

ar-lb

ARABIC

LEBANNON

Arabic (Libya)

ar-ly

ARABIC

LIBYA

Arabic (Morocco)

ar-ma

ARABIC

MOROCCO

Arabic (Oman)

ar-om

ARABIC

OMAN

Arabic (Qatar)

ar-qa

ARABIC

QATAR

Arabic (Saudi Arabia)

ar-sa

ARABIC

SAUDI ARABIA

Arabic (Syria)

ar-sy

ARABIC

SYRIA

Arabic (Tunisia)

ar-tn

ARABIC

TUNISIA

Arabic (U.A.E.)

ar-ae

ARABIC

UNITED ARAB EMIRATES

Arabic (YEMEN)

ar-ye

ARABIC

YEMEN

Assamese

as

ASSAMESE

INDIA

Basque

eu

FRENCH

FRANCE

Belarusian

be

RUSSIAN

RUSSIA

Bengali

bn

BANGLA

BANGLADESH

Bulgarian

bg

BULGARIAN

BULGARIA

Catalan

ca

CATALAN

CATALONIA

Chinese

zh

SIMPLIFIED CHINESE

CHINA

Chinese (China)

zh-cn

SIMPLIFIED CHINESE

CHINA

Chinese (Hong Kong SAR)

zh-hk

TRADITIONAL CHINESE

HONG KONG

Chinese (Macau SAR)

zh-mo

TRADITIONAL CHINESE

HONG KONG

Chinese (Singapore)

zh-sg

SIMPLIFIED CHINESE

SINGAPORE

Chinese (Taiwan)

zh-tw

TRADITIONAL CHINESE

TAIWAN

Croatian

hr

CROATIAN

CROATIA

Czech

cs

CZECH

CZECH REPUBLIC

Danish

da

DANISH

DENMARK

Dutch (Belgium)

nl-be

DUTCH

BELGIUM

Dutch (Netherlands)

nl

DUTCH

THE NETHERLANDS

English

en

AMERICAN

AMERICA

English (Australia)

en-au

ENGLISH

AUSTRALIA

English (Belize)

en-bz

ENGLISH

UNITED KINGDOM

English (Canada)

en-ca

ENGLISH

CANADA

English (Ireland)

en-ie

ENGLISH

IRELAND

English (Jamaica)

en-jm

ENGLISH

UNITED KINGDOM

English (New Zealand)

en-nz

ENGLISH

NEW ZEALAND

English (Philippines)

en-ph

ENGLISH

PHILIPPINES

English (South Africa)

en-za

ENGLISH

SOUTH AFRICA

English (Trinidad)

en-tt

ENGLISH

UNITED KINGDOM

English (United Kingdom)

en-gb

ENGLISH

UNITED KINGDOM

English (United States)

en-us

AMERICAN

AMERICA

English (Zimbabwe)

en-zw

ENGLISH

UNITED KINGDOM

Estonian

et

ESTONIAN

ESTONIA

Faeroese

fo

ENGLISH

UNITED KINGDOM

Farsi

fa

ENGLISH

UNITED KINGDOM

Finnish

fi

FINNISH

FINLAND

French (Belgium)

fr-be

FRENCH

BELGIUM

French (Canada)

fr-ca

CANADIAN FRENCH

CANADA

French (France)

fr

FRENCH

FRANCE

French (Luxembourg)

fr-lu

FRENCH

LUXEMBOURG

French (Monaco)

fr-mc

FRENCH

FRANCE

French (Switzerland)

fr-ch

FRANCH

SWITZERLAND

FYRO Macedonian

mk

MACEDONIAN

FYR MACEDONIA

Gaelic

gd

ENGLISH

UNITED KINGDOM

Galician

gl

SPANISH

SPAIN

German (Austria)

de-at

GERMAN

AUSTRIA

German (Germany)

de

GERMAN

GERMANY

German (Liechtenstein)

de-li

GERMAN

GERMANY

German (Luxemgourg)

de-lu

GERMAN

LUXEMBOURG

German (Switzerland)

de-ch

GERMAN

SWITZERLAND

Greek

el

GREEK

GREECE

Gujarati

gu

GUJARATI

INDIA

Hebrew

he

HEBREW

ISRAEL

Hindi

hi

HINDI

INDIA

Hungarian

hu

HUNGARIAN

HUNGARY

Icelandic

is

ICELANDIC

ICELAND

Indonesian

id

INDONESIAN

INDONESIA

Italian (Italy)

it

ITALIAN

ITALY

Italian (Switzerland)

it-ch

ITALIAN

SWITZERLAND

Japanese

ja

JAPANESE

JAPAN

Kannada

kn

KANNADA

INDIA

Kazakh

kk

CYRILLIC KAZAKH

KAZAKHSTAN

Konkani

kok

KOREAN

KOREA

Korean

ko

KOREAN

KOREA

Kyrgyz

kz

RUSSIAN

RUSSIA

Latvian

lv

LATVIAN

LATVIA

Lithuanian

lt

LITHUANIAN

LITHUANIANA

Malay (Malaysia)

ms

MALAY

MALAYSIA

Malayalam

ml

MALAYALAM

INDIA

Maltese

mt

ENGLISH

UNITED KINGDOM

Marathi

mr

ENGLISH

INDIA

Nepali (India)

ne

ENGLISH

UNITED KINGDOM

Norwegian (Bokmal)

nb-no

NORWEGIAN

NORWAY

Norwegian (Bokmal)

no

NORWEGIAN

NORWAY

Norwegian (Nynorsk)

nn-no

NORWEGIAN

NORWAY

Oriya

or

ORIYA

INDIA

Polish

pl

POLISH

POLAND

Portuguese (Brazil)

pt-br

BRAZILIAN PORTUGUESE

BRAZIL

Portuguese (Portugal)

pt

PORTUGUESE

PORTUGAL

Punjabi

pa

PUNJABI

INDIA

Romanian

ro

ROMANIAN

ROMANIA

Russian

ru

RUSSIAN

RUSSIA

Russian (Moldova)

ru-md

RUSSIAN

RUSSIA

Serbia

sr

CYRILLIC SERBIAN

SERBIA AND MONTENEGRO

Slovak

sk

SLOVAK

SLOVAKIA

Slovenian

sl

SLOVENIAN

SLOVENIA

Spanish (Argentina)

es-ar

LATIN AMERICAN SPANISH

ARGENTINA

Spanish (Bolivia)

es-bo

LATIN AMERICAN SPANISH

ARGENTINA

Spanish (Chile)

es-cl

LATIN AMERICAN SPANISH

CHILE

Spanish (Colombia)

ec-co

LATIN AMERICAN SPANISH

COLOMBIA

Spanish (Costa Rica)

es-cr

LATIN AMERICAN SPANISH

COSTA RICA

Spanish (Dominican Republic)

es-do

LATIN AMERICAN SPANISH

PUERTO RICO

Spanish (Ecuador)

es-ec

LATIN AMERICAN SPANISH

ECUDOR

Spanish (El Salvador)

es-sv

LATIN AMERICAN SPANISH

EL SALVADOR

Spanish (Guatemala)

es-gt

LATIN AMERICAN SPANISH

GUATEMALA

Spanish (Honduras)

es-hn

LATIN AMERICAN SPANISH

GUATEMALA

Spanish (Mexico)

es-mx

MEXICAN SPANISH

MEXICO

Spanish (Nicaragua)

es-ni

LATIN AMERICAN SPANISH

Nicaragua

Spanish (Panama)

es-pa

LATIN AMERICAN SPANISH

Panama

Spanish (Paraguay)

es-py

LATIN AMERICAN SPANISH

ARGENTINA

Spanish (Peru)

es-pe

LATIN AMERICAN SPANISH

PERU

Spanish (Puerto Rico)

es-pr

LATIN AMERICAN SPANISH

PUERTO RICO

Spanish (Traditional Sort)

es

LATIN AMERICAN SPANISH

SPAIN

Spanish (United States)

es-us

LATIN AMERICAN SPANISH

AMERICAN

Spanish (Uruguay)

es-uy

LATIN AMERICAN SPANISH

ARGENTINA

Spanish (Venezuela)

es-ve

LATIN AMERICAN SPANISH

VENEZUELA

Swedish

sv

SWEDISH

SWEDEN

Swedish

sv-fi

SWEDISH

FINLAND

Tamil

ta

TAMIL

INDIA

Telugu

te

TELUGU

INDIA

Thai

th

THAI

THAILAND

Turkish

tr

TURKISH

TURKEY

Ukrainian

uk

UKRAINIAN

UKRAINE

Urdu

ur

ENGLISH

UNITED KINGDOM

Uzbek

uz

LATIN UZBEK

UZBEKISTAN

Vietnamese

vi

VIETNAMESE

VIETNAM


Conclusion
By configuring NLS_TERRITORY at the session level within your APEX application, you align data presentation with regional expectations. Whether based on user preferences, browser language, or application logic, setting this parameter correctly provides users with a more intuitive and culturally consistent experience across your app.

 

How Do I Implement Oracle APEX NLS_TERRITORY in APEX

Introduction
Implementing NLS_TERRITORY in Oracle APEX is an important step for tailoring your application’s behavior to regional conventions. The NLS_TERRITORY setting controls how dates, numbers, currencies, and other locale-sensitive data are formatted based on the user’s territory or country. By configuring this setting correctly, you ensure that users see data displayed in formats that align with their regional expectations, improving usability and professionalism.

Implementing NLS_TERRITORY in Oracle APEX is key to ensuring your application respects regional formatting conventions for dates, numbers, currencies, and more. The NLS_TERRITORY setting controls locale-specific display aspects by defining the territory or country whose conventions should be applied during the user session.

Here is a detailed guide on how to implement and manage NLS_TERRITORY in Oracle APEX:

  1. Understand the Purpose of NLS_TERRITORY
    The NLS_TERRITORY parameter influences default date formats, numeric characters (such as decimal and group separators), currency symbols, and week definitions. For example, NLS_TERRITORY set to US uses the mm/dd/yyyy date format and a dot (.) as the decimal separator, while DE (Germany) uses dd.mm.yyyy and a comma (,) as the decimal separator.

  2. Set NLS_TERRITORY at the Database Level
    You can check or set the default NLS_TERRITORY at the database or instance level with SQL commands like:

    SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = 'NLS_TERRITORY';
    

    To change it permanently, database initialization parameters or ALTER SESSION commands can be used by DBAs.

  3. Override NLS_TERRITORY at the Session Level in APEX
    Since Oracle APEX manages sessions independently, you should set NLS_TERRITORY per user session to reflect their regional preferences. Use a Before Header process or an initialization PL/SQL block in your application:

    BEGIN
      EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''DE''';
    END;
    

    You can dynamically set this based on the user’s language selection or profile, for example:

    BEGIN
      IF :APP_LANGUAGE = 'de' THEN
        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''DE''';
      ELSIF :APP_LANGUAGE = 'en' THEN
        EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TERRITORY = ''US''';
      END IF;
    END;
    
  4. Use Application Items or Preferences
    Store the user’s territory preference in an application item (e.g., P0_TERRITORY) or user profile table. Reference this value in your session initialization process to set the correct NLS_TERRITORY.

  5. Ensure UI Elements Reflect Territory Settings
    APEX date pickers, number fields, and reports automatically respect NLS_TERRITORY settings at the session level. Verify that format masks and regional settings in page items align with expected territory formats.

  6. Handle Multi-Territory Applications
    For applications supporting multiple territories, implement logic to dynamically set NLS_TERRITORY based on user choice or browser locale. This can be combined with language settings to deliver a fully localized experience.

  7. Test for Correctness
    Thoroughly test date formats, numeric displays, currency symbols, and sorting behavior under different NLS_TERRITORY settings. Validate with real user data and expected regional formats.

By carefully implementing NLS_TERRITORY in Oracle APEX at the session level, you ensure that your application respects regional data conventions. This results in a more natural, user-friendly interface that aligns with user expectations worldwide, enhancing both usability and professionalism.

 

Conclusion
Effectively implementing NLS_TERRITORY in Oracle APEX enhances the localization and regional accuracy of your application. By setting and managing this parameter at the session or application level, you provide users with familiar data formats that match their territory’s standards. This attention to detail helps create a more intuitive and globally friendly user experience.

 

How Do I Use the Supported Globalization Codes in Oracle APEX

 

Introduction
Using supported globalization codes in Oracle APEX is essential for developing applications that cater to a global audience. These codes define language, territory, and regional settings that influence how dates, numbers, currencies, and text are displayed and processed. Understanding and applying the correct globalization codes ensures that your application respects local conventions and provides users with a familiar, intuitive experience regardless of their location.

 

Using supported globalization codes in Oracle APEX is a fundamental step in building applications that correctly handle language, regional settings, and data formats such as dates, numbers, and currencies. Globalization codes are standardized identifiers that define language and territory conventions, enabling your application to present information in a way that aligns with users’ cultural and regional expectations.

Here is a detailed guide on how to use supported globalization codes in Oracle APEX:

  1. Understand Globalization Codes Format
    Globalization codes typically follow the format language[_territory], where:

    • Language is a two-letter ISO 639-1 code (e.g., en for English, fr for French, ja for Japanese).

    • Territory is a two-letter ISO 3166-1 alpha-2 country code (e.g., US for United States, FR for France).
      For example, en_US represents English as spoken in the United States, while fr_FR stands for French in France.

  2. Set Primary Language and Globalization Attributes
    In your Oracle APEX application, go to Shared Components > Globalization Attributes. Here, you can:

    • Specify the Primary Language using a globalization code (e.g., en_US).

    • Set the Application Primary Time Zone and Date Format consistent with the target region.

  3. Add Supported Languages
    Under Shared Components > Languages, add the globalization codes corresponding to the languages and territories your application will support. These codes will be used to control translations and locale-specific formatting.

  4. Control Session Language and Locale
    Oracle APEX determines the session language using several methods, including browser preferences, application items, or URL parameters. You can programmatically set the session language using PL/SQL:

    BEGIN
      APEX_UTIL.SET_SESSION_LANG('fr_FR');
    END;
    

    This sets the language and regional context for the user session.

  5. Use Globalization Codes in SQL and PL/SQL
    You can reference globalization codes in your SQL queries or PL/SQL logic to control formatting or data retrieval based on user locale. For example, using TO_CHAR with a format model that adapts to locale or using NLS_SESSION_PARAMETERS:

    SELECT value
    FROM nls_session_parameters
    WHERE parameter = 'NLS_LANGUAGE';
    
  6. Format Items Based on Locale
    When designing page items (date pickers, number fields), you can use the globalization code to dynamically apply format masks appropriate for the user’s locale. This ensures that dates, numbers, and currencies appear in familiar formats.

  7. Translate Application Text Based on Language Codes
    The globalization codes correspond to the language codes used in the APEX translation framework. When exporting and importing translation files, make sure to use the correct globalization codes to match target languages.

  8. Test Multi-Language and Regional Support
    Switch session languages and territories during testing to verify that your application displays data correctly for each locale. Check for date formatting, numeric separators, currency symbols, and translated text.

By effectively using supported globalization codes, Oracle APEX developers can create applications that adapt dynamically to user language and regional preferences. This leads to improved usability, better international reach, and a polished user experience tailored to diverse audiences worldwide.

Oracle APEX provides built-in globalization codes that determine how an application behaves in different languages, date formats, number formats, and regional settings. These codes are automatically set based on the Globalization Attributes selected at the application level. Understanding these codes is essential for building multilingual applications that display data correctly based on the user's locale.


What Are Globalization Codes?

Globalization codes control various language and region-based behaviors in an APEX application, such as:

  • Application language (determines which translated text is shown)

  • Date and number formatting (e.g., DD/MM/YYYY vs. MM/DD/YYYY)

  • Currency symbols (e.g., $ for USD vs. € for EUR)

  • Sorting and collation rules (e.g., alphabetical order differences across languages)

These codes are applied at the session level, meaning they can dynamically change based on the user's preferences.


Where Are Globalization Codes Set?

Globalization settings are primarily controlled in Application Attributes under the Globalization section. You can configure:

  1. Primary Language – The default language in which the application is developed.

  2. Application Language Derived From – Determines how the user’s language is selected: 

    • User’s browser settings

    • A specific APEX item

    • A PL/SQL function

  3. Date and Number Format Derived From – Defines whether date and number formats follow: 

    • Application language

    • User’s browser settings

    • A specific APEX item

These settings impact how APEX renders content and interacts with database data.


Common Globalization Codes in Oracle APEX

Globalization Code

Description

Example Value

NLS_LANGUAGE

Specifies the language for sorting and text display

'ENGLISH', 'FRENCH'

NLS_TERRITORY

Defines number, currency, and date formats

'UNITED STATES', 'GERMANY'

NLS_DATE_FORMAT

Controls the format for displaying dates

'DD-MON-YYYY', 'YYYY-MM-DD'

NLS_CURRENCY

Defines the currency symbol for number formatting

'€', '$'

NLS_SORT

Specifies sorting rules for character data

'BINARY', 'GERMAN'

NLS_NUMERIC_CHARACTERS

Determines decimal and thousands separators

'. ,' (US), ', .' (EU)

These values are set automatically but can be overridden using PL/SQL code.


Retrieving and Modifying Globalization Codes

You can check the current globalization settings using SQL:

SELECT 

    SYS_CONTEXT('USERENV', 'NLS_LANGUAGE') AS language,

    SYS_CONTEXT('USERENV', 'NLS_TERRITORY') AS territory,

    SYS_CONTEXT('USERENV', 'NLS_DATE_FORMAT') AS date_format,

    SYS_CONTEXT('USERENV', 'NLS_CURRENCY') AS currency

FROM DUAL;

This query returns the session-specific settings for language, territory, and date formats.

To manually change these settings at the session level, use:

ALTER SESSION SET NLS_LANGUAGE = 'FRENCH';

ALTER SESSION SET NLS_TERRITORY = 'FRANCE';

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YYYY';

This modifies the behavior for the current session only.


Controlling Globalization in APEX Applications

In Oracle APEX, you can dynamically control globalization settings using Dynamic Actions or PL/SQL processes.

Example: Setting the Application Language from a Select List

  1. Add a Select List (P0_LANGUAGE) with values 'en', 'fr', 'es'.

  2. Create a PL/SQL Process to set the session language:

BEGIN

    APEX_UTIL.SET_SESSION_LANG(:P0_LANGUAGE);

END;

  1. Refresh the page so that the language changes dynamically.

This ensures users can switch languages at runtime.


Best Practices for Using Globalization Codes

  • Always set consistent NLS parameters for date and number formatting to prevent errors.

  • Store translations separately using APEX’s built-in translation features.

  • Use APEX_UTIL.SET_SESSION_LANG to dynamically change the application language.

  • Test applications in different locales to ensure all formatting rules work as expected.

  • Consider NLS_SORT settings when performing text searches to ensure correct results across languages.

By understanding and managing globalization codes in Oracle APEX, developers can build applications that automatically adapt to different languages, number formats, and regional preferences, ensuring a smooth user experience for international audiences.

 Conclusion
Mastering supported globalization codes in Oracle APEX allows developers to build truly internationalized applications that adapt seamlessly to different languages and regional preferences. By leveraging these codes for language and territory settings, you can enhance data formatting, improve user interaction, and make your applications more accessible and relevant to users around the world.

UI Defaults

 In Oracle APEX, User Interface (UI) Defaults are a set of metadata-driven, table- and column-scoped attributes that APEX consults when it g...