Modifying NLS_DATE format without "Alter Session"
Different 3rd party apps require different NLS_DATE_FORMAT.
How can we set different format at user / schema level, as we do not have access to application code to do 'Alter Session'?
Can we use any concept in VDB?
Regards
Pravesh Babhoota
Hi,
At the schema level, code an "after insert or updata" trigger" such that your column data format is stored in the application column in the DATE FORMAT you desire for reporting:
ie. use this in a trigger
SELECT TO_CHAR(app_column, 'DD-MON-YYYY HH:MI:SS')
FROM app_table;
SQL trigger format:
create or replace trigger <TRIGGER_NAME>
before insert or update
on <table_name>
for each row
declare
<VARIABLE DECLARATIONS>
begin
<CODE>
exception
<EXCEPTION HANDLERS>
end <TRIGGER_NAME>;
/
Similar Messages
-
Date format with alter session -- very urgent !!!!
The default format of date is DD-MON-YY.
I like to change as DD/MM/YYYY. So I tried to do so by going
through my login in SQLPlus and wrote
ALTER SESSION
SET NLS_DATE_FORMAT = 'DD/MM/YYYY'.
The format got changed and there after every query displayed
date in dd/mm/yyyy format. But once I exit sqlplus and reenter
in sqlplus, the format goes away and the default date format i.e
dd-mon-yy comes in existence.
I want to know, how can i make my date format permanent and too
for all users.
nullhello Khan,
You can set this format in 2 ways, one is
local setting and the other one is on server setting.
Edit your c:\windows\oracle.ini (local setting)
or your init.ora (oracle server setting)
and add this script
SET NLS_DATE_FORMAT = 'DD/MM/YYYY'
note: if there's no nls_date_format in oracle.ini, the server
nls_date_format in init.ora will be the current setting
on your PC
Hope this will help
NEC PHIl.
Shamsad Khan (guest) wrote:
: The default format of date is DD-MON-YY.
: I like to change as DD/MM/YYYY. So I tried to do so by going
: through my login in SQLPlus and wrote
: ALTER SESSION
: SET NLS_DATE_FORMAT = 'DD/MM/YYYY'.
: The format got changed and there after every query displayed
: date in dd/mm/yyyy format. But once I exit sqlplus and reenter
: in sqlplus, the format goes away and the default date format
i.e
: dd-mon-yy comes in existence.
: I want to know, how can i make my date format permanent and
too
: for all users.
null -
Is it possible to use "english hijrah" on-the-fly without ALTER SESSION?
SQL> alter session set nls_calendar='english hijrah';
Session altered.
SQL> select '29-02-1435', TO_DATE('29-02-1435', 'DD-MM-RRRR') from dual;
'29-02-1435' TO_DATE('29-02-1435','DD-MM-RRRR')
29-02-1435 29 Safar 1435
Hi, the above shows that an input date of '29-02-1435' can be validated as a correct Hijrah date.
However, is it possible to do such a TO_DATE(), or TO_CHAR() conversion without the overhead of an 'ALTER SESSION' at the start ?
From within a Gregorian session I tried a few things like below, but they didn't work and give ORA-01756: quoted string not properly terminated
select TO_CHAR('29-02-1435', 'nls_calendar="English Hijrah"', 'nls_date_format="DD-MM-RRRR")
from dual;
All we're needing to do is validate the date as valid Hijrah - no further processing is done.
Many thanks for any help. MarkSorry - I had been confusing single and double quotes.
The following shows that it's a valid Arabic date
SQL> select '29-02-1435', TO_DATE('29-02-1435', 'DD-MM-RRRR', 'nls_calendar=''English Hijrah''')
2 from dual;
'29-02-1435' TO_DATE('29-02-
29-02-1435 02-JAN-14
and for example if you put a crazy month, it complains
SQL> select '29-02-1435', TO_DATE('29-92-1435', 'DD-MM-RRRR', 'nls_calendar=''English Hijrah''')
2 from dual;
select '29-02-1435', TO_DATE('29-92-1435', 'DD-MM-RRRR', 'nls_calendar=''English Hijrah''')
ERROR at line 1:
ORA-01843: not a valid month -
Alter session enable parallel dml
Is it necessary to alter session in oracle 11gR2 using "alter session enable parallel dml" to execute parallell DML?Oracle will not use Degree of parallelism in DML statement without altering session even if there is DOP mention in the DML query?
Thanks,Yes, http://docs.oracle.com/cd/E11882_01/server.112/e25523/parallel003.htm#CACFJJGG
A DML statement can be parallelized only if you have explicitly enabled parallel DML in the session, as in the following statement:ALTER SESSION ENABLE PARALLEL DML; -
Modify DATE format only for a column
DB table has two or more columns of DATE type of which a column representing "Date of Birth" should not be of the format of TIMESTAMP . When queried it should return "mm/dd/yyyy" format without 'hh:mm:ss' . The others should be as usual.
This is to ensure no changes in the applications querying this columns
Any hints appreciated
ThanksIt depends on NLS_DATE_FORMAT and NLS_TIMESTAMP_FORMAT that is set in the database or session and the datatye used in the table, here is an example:-
U1@BABU> CREATE TABLE TEST_TAB (DATE1 DATE, DATE2 TIMESTAMP);
Table created.
U1@BABU> INSERT INTO TEST_TAB VALUES (SYSDATE,SYSDATE);
1 row created.
U1@BABU> COMMIT;
Commit complete.
U1@BABU> SELECT * FROM TEST_TAB;
DATE1 DATE2
22-DEC-06 22-DEC-06 11.44.18.000000 AM
U1@BABU> SELECT * FROM NLS_SESSION_PARAMETERS;
PARAMETER VALUE
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
17 rows selected.
U1@BABU> ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS';
Session altered.
U1@BABU> SELECT * FROM TEST_TAB;
DATE1 DATE2
22-DEC-2006 11:44:18 22-DEC-06 11.44.18.000000 AM
U1@BABU> SELECT TO_CHAR(DATE1,'MON-DD-YYYY HH24:MI:SS') DATE1, TO_CHAR(DATE2,'Month DD YYYY') DATE2
FROM TEST_TAB;
DATE1 DATE2
DEC-22-2006 11:44:18 December 22 2006 -
RMAN-11003: failure during parse/execution of SQL statement: alter session
without doing any changes I have started getting the following error in the RMAN logs.
i didnt any changes related to sort_area_size but getting the error below
plz help guys
RMAN logs
=====================
connected to recovery catalog database
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of allocate command at 12/03/2007 22:00:01
RMAN-03014: implicit resync of recovery catalog failed
RMAN-03009: failure of full resync command on default channel at 12/03/2007 22:00:01
RMAN-11003: failure during parse/execution of SQL statement: alter session set sort_area_size=10485760
ORA-00068: invalid value 10485760 for parameter sort_area_size, must be between 0 and 1Hi:
It seems when you are starting RMAN it's executing some commands (one 'ALTER SESSION...'. It's seems to be a batch which has a bad value for SORT_AREA_SIZE. Find it and modify to a proper value as message shows. If you can't find start RMAN by calling directly the executable ($ORACLE_HOME/bin/rman or %ORACLE_HOME%/bin/rman.exe). -
Create view and alter Session gets 0RA-01031
I can't create a view after using ALTER SESSION set current_schema without using an explicit schema. I get ORA-01031. Is this a known bug? Here are the details:
1. Log on as SYSTEM
2. ALTER SESSION set current_schema=FRED;
3. CREATE VIEW vFoo as select * from Foo; -- ORA-01031: insufficient privileges
4. CREATE VIEW FRED.vFoo as select * from Foo; -- this works!
I've read where some privileges need to be granted directly. In fact, if Fred grants select privilege on Foo to SYSTEM, the statement in #3 above works. However, something doesn't seem right because why does #4 succeed without the GRANT?
In case you're wondering why I don't just use #4 above, which does work, it's because I've got a script that will be run by customers to create tables, views, etc. in an arbitrary schema and the schema is associated with a user with limited permissions. Hence, the use of the ALTER SESSION.See, You looged as SYSTEM (Scheme = SYSTEM)
Now you alter your session to another schema FRED.
Now if you want to access SCHEMA of FRED, You need to connect first.
SQL > connect user/password@host
Then
SQL > CREATE VIEW vFoo as select * from Foo;
View created. -
Alter session set NLS_DATE_FORMAT and to_date not working
Hey folks,
for the sake of simplicity let's assume i want to get the current system time from the table dual in a certain format, e.g. 'YY.MM.DD'.
Currently the query
select sysdate from dual;
yields:
07-JAN-08
The desired output should look like this:
08.01.07
So, according to the manual, i tried the following:
alter session set NLS_DATE_FORMAT = 'yy.mm.dd';
No effect, date is still displayed as
07-JAN-08
Even the following query:
select TO_DATE (sysdate, 'yy.mm.dd') from dual;
yields
07-JAN-08
What am i doing wrong here?
Additional information:
-> DB is Oracle 9
-> I am using the Oracle SQL Developer under Ubuntu Gutsy
-> No, i did not forget to commit my commands....:-)
Any ideas?select TO_CHAR (sysdate, 'yy.mm.dd') from dual;However the alter session command should work:
SQL*Plus: Release 9.2.0.2.0 - Production on Mon Jan 7 14:32:26 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
SQL> alter session set NLS_DATE_FORMAT = 'yy.mm.dd';
Session altered.
SQL> select sysdate from dual;
SYSDATE
08.01.07
SQL> Note: There is nothing to commit here. Only selects, no DML.
Message was edited by:
Sven W. -
RMAN-10006: error running SQL statement: alter session set remote_dependenc
Backups are failing with following error
RMAN-00554: initialization of internal recovery manager package failed
RMAN-12001: could not open channel default
RMAN-10008: could not create channel context
RMAN-10002: ORACLE error: ORA-00096: invalid value SIGNATURE for parameter remote_dependencies_mode, must be from among MANUAL, AUTO
RMAN-10006: error running SQL statement: alter session set remote_dependencies_mode = signature
Not able to change to signature
SQL> alter session set remote_dependencies_mode=signature;
ERROR:
ORA-00096: invalid value SIGNATURE for parameter remote_dependencies_mode, must
be from among MANUAL, AUTO
I dont see MANUAL or AUTO as valid value for this parameter (http://download.oracle.com/docs/cd/B10501_01/server.920/a96536/ch1175.htm#1023124) DB version is 9.2.0
Parameter type
String
Syntax
REMOTE_DEPENDENCIES_MODE = {TIMESTAMP | SIGNATURE}
Default value
TIMESTAMP
Parameter class
Dynamic: ALTER SESSION, ALTER SYSTEM
=======================================
I believe it could be because of following bug
"A PRE-PATCHED ORACLE IMAGE CAN BE INSTALLED IN MEMORY "
Refer: "https://metalink2.oracle.com/metalink/plsql/f?p=130:15:1613505143885559758::::p15_database_id,p15_docid,p15_show_header,p15_show_help,p15_black_frame,p15_font:BUG,4610411,1,1,1,helvetica"
I appreciate your effort in fixing this issue.
Edited by: user10610722 on Nov 25, 2008 4:37 PMHi:
It seems when you are starting RMAN it's executing some commands (one 'ALTER SESSION...'. It's seems to be a batch which has a bad value for SORT_AREA_SIZE. Find it and modify to a proper value as message shows. If you can't find start RMAN by calling directly the executable ($ORACLE_HOME/bin/rman or %ORACLE_HOME%/bin/rman.exe). -
Adding audio and/or video without altering time line...
I currently have a completed i-movie project of which I wanted to add some "stuff" at the begining of the presentation and actually at one point in the middle. I want to "insert" this audio and a few slides without altering the rest of the project. Am I am to anchor points so that what ever I do around those points does not affect the timing of what is already there?
Thanks in advance all.
JColeHi
First your server does not require javascript only your browser, (standard in all modern browsers).
You also do not necessarily require the flash program, (your browser will require a plug-in for the audio video to play).
You will require some form of video/media encoding software to convert your files to the required format though, (do a search using your preferred search engine for video encoder), then use dreamweavers insert file option to insert your audio/video file into your html
PZ
www.pziecina.com -
Oracle Alter Session not working in CF9
Hello,
I'm trying to understand differences between CF5 and CF9 when I retrieve numbers and dates from an Oracle Database.
The code I ran on CF5 and CF9 servers :
<cfoutput>
<cftransaction>
<cfquery datasource="intranet">
alter session SET NLS_TERRITORY = FRANCE
</cfquery>
<cfquery name="qry" datasource="intranet">
select
TO_NUMBER(12345/10) as nbr,
sysdate as dt,
TO_CHAR(1234.56,'L99G999D99') as cur
from dual
</cfquery>
</cftransaction>
#qry.nbr#<br>
#qry.dt#<br>
#qry.cur#
</cfoutput>
I've got those outputs :
Result in CF5
Result in CF9
1234,5
01/12/09
¿1.234,56
1234.5
2009-12-01 19:16:04.0
¿1.234,56
The first two rows in CF5 display data in French format. That's not the same for CF9, the data are in American format.
Then I changed the NLS_TERRITORY parameter
alter session SET NLS_TERRITORY = AMERICA
Result in CF5
Result in CF9
1234.5
01-DEC-09
$1,234.56
1234.5
2009-12-01 19:20:39.0
$1,234.56
The two first row haven't changed in CF9, it seems that the "alter session" has no effect on number and date format in query results. Is that a bug or am I misunderstanding something ?
Regards,
MaximeThank you for your reply.
I tried what you've suggested on the CF9 server.
The results are :
NLS_TERRITORY =
1) oracle JDBC database
2) oracle JDBC thin client
3) oracle JDBC-ODBC bridge
AMERICA
1234.5
2009-12-02 13:24:30.0
$1,234.56
1234.5
{ts '2009-12-02 00:00:00'}
$1,234.56
1234.5
2009-12-02 13:24:30.0
$1,234.56
FRANCE
1234.5
2009-12-02 13:29:53.0
¿1.234,56
1234.5
{ts '2009-12-02 00:00:00'}
¿1.234,56
1234.5
2009-12-02 13:29:53.0
¿1.234,56
The behavior is pretty much the same in the three differents ways to call the database. The only difference is on the date display using the Oracle JDBC thin client, which is another format from those I've already got.
Regards,
Maxime -
How to improve sql perfomance/access speed by altering session parameters
Dear friends
how to improve sql perfomance/access speed by altering the session parameters? without altering indexes & sql expression
regrads
Edited by: sak on Mar 14, 2011 2:10 PM
Edited by: sak on Mar 14, 2011 2:43 PMOne can try:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:3696883368520
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:5180609822543
http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/memory.htm#sthref497
But make sure you understand the caveats you can run into!
It would be better to post the outcome of select * from v$version; first.
Also and execution plan would be nice to see.
See:
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting -
Execute immediate 'alter session set current_schema = ' failed in PL/SQL
Hi
I am trying to run
EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST ' ;
in a pl/sql block but it is failing.Can anyone update me on this.
CREATE OR REPLACE PROCEDURE test3
IS
A_COUNT NUMBER(15);
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST ' ;
SELECT COUNT(*) INTO A_COUNT FROM (
select id from solutions );
END;
/The user who owns the procedure needs to be granted direct select rights on table test.solutions (not via a role). Still will not help. Look what OP is trying to do. In a stored procedure owned by some user (other than TEST) OP is trying to reference user TEST owned table solution without prefixing it with owner. Something like:
SQL> create table u1.test_tbl(x number);
Table created.
SQL> select * from test_tbl;
select * from test_tbl
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> alter session set current_schema = U1;
Session altered.
SQL> select * from test_tbl;
no rows selected
SQL> However, OP tries to do it in a SP using dynamic SQL to change current schema to test. Such change will occur when SP will be executed, not when is it compiled. At compile time we are still under SP owner's schema and therefore select from solutions implies table solutions owned by SP owner, not by TEST. The only way to make SP compile and work OK is to select from solutions also dynamically:
SQL> select sys_context('userenv','current_schema') from dual
2 /
SYS_CONTEXT('USERENV','CURRENT_SCHEMA')
SCOTT
SQL> CREATE OR REPLACE PROCEDURE test3
2 IS
3 A_COUNT NUMBER(15);
4 BEGIN
5 EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = U1' ;
6 SELECT COUNT(*) INTO A_COUNT FROM (
7 select x from test_tbl );
8 END;
9 /
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE TEST3:
LINE/COL ERROR
6/1 PL/SQL: SQL Statement ignored
7/15 PL/SQL: ORA-00942: table or view does not exist
SQL> set serveroutput on
SQL> CREATE OR REPLACE PROCEDURE test3
2 IS
3 A_COUNT NUMBER(15);
4 c sys_refcursor;
5 BEGIN
6 EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = U1' ;
7 OPEN C FOR 'SELECT COUNT(*) FROM (select x from test_tbl )';
8 FETCH c INTO A_COUNT;
9 dbms_output.put_line(a_count);
10 CLOSE c;
11 END;
12 /
Procedure created.
SQL> insert into u1.test_tbl select rownum from emp;
14 rows created.
SQL> exec test3
14
PL/SQL procedure successfully completed.
SQL> Obviously, as you noted SP owner must have directly granted select on test3.solutions.
SY. -
Hi All,
I have created process to alter session so I control the currency format, any way the process is working fine on the home page, but when visit another page or return to the home page the session value (currency format )will go back to previous setting ($). How can I keep this session consistent and fixed across my website?
Also when I change the order by for any report the currency format will be shown in older setting ($), I’m using PPR reports.
PS, when moving between pages the session state is same doesn't change. Also i have tried both application process and page process on new session and on page load.
Thanks,
Fadi.Sorry to bother you with what should be a very stupid question.
I have tried to use the advice given to set the currency for my APEX application.
I used the VPD call in the security attributes tab for my application:
begin
execute immediate 'alter session set nls_territory=''FRANCE''';
execute immediate 'alter session set nls_currency=''€''';
end;
When applying the changes, the euro symbol (€) is set to a reverse question mark (¿)
I can think of a character set problem but no other clue.
Thanks in advance for any interest in my question,
Daniel -
Hi,
I was trying to enable the sql_trace or the events for me to start the tracing utility. I got this following output:
rrkr@ORA10G> alter session set timed_statistics=true;
Session altered.
rrkr@ORA10G> alter session set events '10046 trace name context forever, level 12';
ERROR:
ORA-01031: insufficient privileges
rrkr@ORA10G> alter session set sql_trace=true;
alter session set sql_trace=true
ERROR at line 1:
ORA-01031: insufficient privileges
-- at another session
rrkr_dba@ORA10G> grant alter session to rrkr;
Grant succeeded.
--- back to the first session
rrkr@ORA10G> alter session set sql_trace=true;
Session altered.
rrkr@ORA10G>As you can see I got to execute the timed_statistics, but not the sql_trace. How did that happen if I really dont have the alter session priviledge? Thank you.
Regards,
RhaniIt seems Oracle first checks whether it has to change anything.
It doesn't need to change anything, the statements succeeds, without having checked whether the session has privilege to change the session.
In other cases, you had to change something, privileges were checked, and you got an error.
Privilege checking should occur first.
The internal algorithm is fundamentally flawed.
Sybrand Bakker
Senior Oracle DBA
Maybe you are looking for
-
Hey there :-) I have a late '07 whitebook running Snow Leopard. I write a lot, so after a while its own keyboard can get uncomfortable to me and my freaky long fingers (not to mention rather hot!). I used an external keyboard from the start, at least
-
Dear All, I am using perform statement in script. the code for subroutine in separate program type (e). But unable to get the output. Following is my code of subroutine & form. Regards, Dilip Script code /:PERFORM GET_VAL IN PROGRAM ZGET_VAL
-
Re-edit from IDVD's to Final Cut
I have several DVD's made with IDVD. I would like to retrieve these back to Final Cut Express 4 for some further editing, but I do not have any original video or audio sources except what remains on the DVD's! Is it possible to retreive these back t
-
Can't open file "~Library/Application Support/iWeb/Domain.sites2" from a backup
I've done my home work on this one. I'm trying to recover the Domain.sites2 files from a backup on to an OS 10.6.8 with iWeb 3.0.4. It allows me to create a new site perfectly but I followed these instructions at iwebformusicians including deleting t
-
How to separate telephone numbers in contacts
how to separate telephone numbers in groups of 4 in contacts