Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:50:49+00:00 2026-05-26T16:50:49+00:00

I want to change the NLS_SORT and NLS_COMP parameters for every query to this

  • 0

I want to change the NLS_SORT and NLS_COMP parameters for every query to this particular schema, but there are other users on this system as well that want to keep the original values, so using ALTER SYSTEM SET is a no-no in this case. I also don’t want to change every query to this particular schema.

Is there a way to either put these values in an initialization file that is particular to only this schema or can I somehow add a trigger that sets these values on the session whenever a session is started to this schema?

I am running Oracle Express 11G R2 and the solution does not need to be backwards compatible.

My goal is to not have to run the ALTER SESSION SET rows before running the SELECT-LIKE-statement and having it produce two results rather than one. Here is the Java sample code that I’ve used to examine what values I actually want the NLS_COMP and NLS_SORT values to have:

public class OracleCaseTest {
    public static void main(String[] args) throws SQLException {
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
        dataSource.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
        dataSource.setUsername("CASETEST");
        dataSource.setPassword("casetest");

        Connection conn = null;
        PreparedStatement createStatement = null;
        PreparedStatement populateStatement = null;
        PreparedStatement comparisonAlterSessionStatement = null;
        PreparedStatement sortAlterSessionStatement = null;
        PreparedStatement queryStatement = null;
        PreparedStatement deleteStatement = null;
        ResultSet rs = null;

        conn = dataSource.getConnection();

        createStatement = conn
                .prepareStatement("CREATE TABLE CollationTestTable ( Name varchar(255) )");
        createStatement.execute();

        try {
//            comparisonAlterSessionStatement = conn
//                    .prepareStatement("ALTER SESSION SET NLS_COMP=LINGUISTIC");
//            comparisonAlterSessionStatement.execute();
//
//            sortAlterSessionStatement = conn.prepareStatement("ALTER SESSION SET NLS_SORT=BINARY_CI");
//            sortAlterSessionStatement.execute();

            String[] names = { "pepe", "pépé", "PEPE", "MEME", "mémé", "meme" };
            for (String name : names) {
                populateStatement = conn
                        .prepareStatement("INSERT INTO CollationTestTable VALUES (?)");
                populateStatement.setString(1, name);
                populateStatement.execute();
            }

            queryStatement = conn
                    .prepareStatement("SELECT Name FROM CollationTestTable WHERE NAME LIKE 'pe%'");
            rs = queryStatement.executeQuery();

            while (rs.next()) {
                System.out.println(rs.getString(1));
            }
        } finally {

            deleteStatement = conn.prepareStatement("DROP TABLE CollationTestTable");
            deleteStatement.execute();
        }
    }
}

I’m aware of the problem with full table scans without linguistic indexes that this might create, but ignore that for this question.

UPDATE: This is the statement I used to create my trigger from the SQL command-line interface (after connecting and logging in with my user):

create or replace trigger nls_settings 
after logon on schema 
begin 
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP=LINGUISTIC'; 
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT=BINARY_CI'; 
end nls_settings; 
/ 

Also changed the original question to indicate that by “database”, in the Oracle world I really meant “schema”/”user”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:50:50+00:00Added an answer on May 26, 2026 at 4:50 pm

    You can create trigger on

    • database startup or instance shutdown
    • user logon or logoff

    http://download.oracle.com/docs/cd/B14117_01/server.101/b10743/triggers.htm#i6061

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm catching only generic exceptions, but i want change this to catch the
i have many div's with the same background image and i want change this
I want to change some properties of a LINQ query result object without creating
I want to change the behaviour of the editable ComboBox. This is the behaviour
I want to change the logging level depending if I'm debbugging or not, but
I want to change the view size for iPhone 3.0, but I find that
For example, I want change PC time in console. C:\Users\user>time The current time is:
i want change this input to dropdown menu. <a href=# onclick=$('#pb1').progressBar(5);>5</a> | <a href=#
I'm programming a Live wallpaper displaying a simple image that I want change every
i used code like this to change color of cell but properties applying only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.