NLS_DATE_FORMAT in NLS_SESSION_PARAMETERS and USERENV is different
534121Dec 19 2008 — edited Feb 4 2009I have got two databases which were created by two different DBA teams.
When I run a package it ran successfully on ORASID1 but failed on ORASID2 with ORA-01861: literal does not match format string. I've found that the query in question is trying to apply a TO_DATE() function on a DATE type column.
Now, my question is: Why the same code didnot fail on SID1.
When I compared the NLS_DATABASE_PARAMETERS, NLS_INSTANCE_PARAMETERS, NLS_SESSION_PARAMETERS, then I did not find any difference.
But, when I checked the NLS parameters using the below query, I found that the NLS_DATE_FORMAT is different.
Note: I checked all the aforesaid settings from sqlplus prompt on the Unix box.
SELECT
SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,
SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,
SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,
SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,
SYS_CONTEXT('USERENV','LANGUAGE') language
FROM DUAL;
ORASID1 NLS Settings:
NLS Territory:AMERICA
NLS Currency:$
NLS Date Format:DD-MON-RR
NLS Date Language:AMERICAN
NLS Sort:BINARY
Language:AMERICAN_AMERICA.UTF8
ORASID2 NLS Settings:
NLS Territory:AMERICA
NLS Currency:$
NLS Date Format:YYYY-MM-DD HH24:MI:SS
NLS Date Language:AMERICAN
NLS Sort:BINARY
Language:AMERICAN_AMERICA.UTF8
Could someone please explain how come the values in nls_session_parameters table are same but when the same value is checked from userenv it shows different results for NLS_DATE_FORMAT?
Thanks in advance.