Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

nls_env parameters

Posted on 2003-11-27
2
Medium Priority
?
2,856 Views
Last Modified: 2008-01-09
How to alter nls_env parameter associated with a job
0
Comment
Question by:adekunbi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
schwertner earned 1500 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

715 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