8

I've got another session that I suspect isn't running with the 'proper' NLS settings for us in Oracle 11gR2. What can I query to show the NLS settings for a different active session - all of the NLS_* views reference my current session.

3
  • There's no nice way of doing it. Either do a session trace or use a DB login trigger to dump the sessions NLS settings to a table for later analysis.
    – Philᵀᴹ
    Commented Sep 18, 2012 at 4:06
  • @Phil - I agree, that is the answer and I think you should post it as one. Commented Sep 18, 2012 at 17:06
  • @LeighRiffel Cheers, have done! ;)
    – Philᵀᴹ
    Commented Sep 18, 2012 at 21:23

2 Answers 2

5

There is no simple way to achieve this. You can either do it by tracing the session or by using a login trigger. Here's an example of how to do it using a DB login trigger.

Logging table:

create table nls_session_parameters_log
(
    inserted_date    date,
    sid              number,
    username         varchar2(128),
    parameter        varchar2(30),
    value            varchar2(40)
);

Public grant and synonym:

grant insert on nls_session_parameters_log to public;

create public synonym nls_session_parameters_log for sys.nls_session_parameters_log;

Database login trigger:

create or replace trigger nls_log_dbtrig after logon on database
begin
  if user in ('PHIL') then
    insert into nls_session_parameters_log
    select sysdate, (select sys_context('USERENV','SID') from dual), (select user from dual),parameter, value
    from nls_session_parameters;
  end if;

  exception
    when others then 
      null;
end;
/

Test:

SQL> conn phil/phil
Connected.
SQL> select count(*) from nls_session_parameters_log;

  COUNT(*)
----------
        17

SQL>

Obviously you'd be better off putting the table in an appropriate schema and granting on a per-user basis.

If you need help with another approach (session tracing), let me know.

2
  • But dumping the information during login won't help if the user changes NLS setting using ALTER SESSION...
    – user1822
    Commented Sep 18, 2012 at 21:32
  • @a_horse_with_no_name Obviously. Tracing is the only option if a session is doing that.
    – Philᵀᴹ
    Commented Sep 18, 2012 at 23:17
1

The only (that i know of) NLS type value that is easily retrievable from the data dictionary is client_charset found in V$SESSION_CONNECT_INFO

ie

select * from V$SESSION_CONNECT_INFO;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.