Solved

nls_env parameters

Posted on 2003-11-27
2
2,650 Views
Last Modified: 2008-01-09
How to alter nls_env parameter associated with a job
0
Comment
Question by:adekunbi
2 Comments
 
LVL 47

Accepted Solution

by:
schwertner earned 500 total points
ID: 9832325
In the view dba_jobs you can find NLS_ENV column. Of course you have to know the job number.


I could not find where to set nls_env column. seems it is recordee by the current session.
But I found an example how to alter this column in the view.

The following is an automated script to correct USER/DBA_JOBS.NLS_ENV  
inconsistencies using an individual job owner approach. Run this script in  
SQL*Plus while logged in as the job owner:
 
 
set serveroutput on;
declare
  -- vars for fetching
  v_job number;
  v_nls varchar2(4000);
  v_what varchar2(4000);
  cursor c1 is
    select job, nls_env, what from user_jobs  
    where  
    ((lower(nls_env) like '%nls_lang=%' or lower(nls_env) like '%nls_territory=%')  
      and not (lower(nls_env) like '%nls_date_forma=t%'))  
    or  
    (lower(nls_env) like '%nls_date_format=%yy%'
      and not lower(nls_env) like '%nls_date_format=%yyyy%');
  -- vars for mask parsing
  v_start number;
  v_end   number;
  v_mask  varchar(256);
  v_date  varchar(256);
  -- vars for dbms_sql
  v_cur   integer;
  v_rc    integer;
begin
  v_cur := dbms_sql.open_cursor;
  dbms_output.put_line('Non Y2K Compliant Jobs');
  dbms_output.put_line('======================');
  open c1;
  loop
    fetch c1 into v_job, v_nls, v_what;
     exit when c1%notfound;
       dbms_output.put_line('Job: '||v_job);
       -- extract the mask
       v_start := instr(lower(v_nls),'nls_date_format=');
       v_end  := instr(lower(v_nls),' nls',v_start);
       v_mask := substr(v_nls,v_start, v_end-v_start);
       dbms_output.put_line(v_mask);
       -- modify the mask (4 possible case combinations)
       v_date := substr(v_mask,instr(v_mask,'=') + 1);
       v_date := replace(v_date,'YY','RR');
       v_date := replace(v_date,'yy','rr');
       v_date := replace(v_date,'Yy','Yy');
       v_date := replace(v_date,'yY','rR');
       dbms_output.put_line('New setting: '||v_date);
       -- change the job
       dbms_sql.parse(v_cur, 'alter session set nls_date_format='||v_date, dbms_sql.v7);
       v_rc := dbms_sql.execute(v_cur);
       dbms_sql.parse(v_cur, 'begin dbms_job.what(:job,:what); end;', dbms_sql.v7);
       dbms_sql.bind_variable(v_cur,':job',v_job);
       dbms_sql.bind_variable(v_cur,':what',v_what);
       v_rc := dbms_sql.execute(v_cur);
       dbms_output.put_line('Success ...');
       dbms_output.put_line('');
  end loop;
  close c1;
  dbms_sql.close_cursor(v_cur);
exception
  when others then
    dbms_output.put_line(sqlerrm);
end;
/
 

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PL/SQL LOOP CURSOR 3 42
Oracle DATE Column Space 11 45
Clone Oracle 12c Database 5 27
Oracle and DateTime math 6 15
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now