To show NLS parameters for session-database-instance together by Pivot and Listagg on 11gr2
Posted by fsengonul on July 21, 2010
I’ve always confused and needed to check for the nls parameters. I thing it’s a good chance to play around with the pivot function on 11gR2 in order to show all of them together.
The pivot function seems to be used only with aggregate functions. How can the text values be aggregated? At this point a new LISTAGG function ,which also comes with 11gr2, is really useful.
After that I have the problem to show the results on terminator. The headings last forever when I do not use aliases on the in clause of pivot. And lastly do not forget to use double quotes for SESSION, just because it is a reserved word.
PARAMETER SESSION DATABASE INSTANCE------------------------------ ------------------------------ ------------------------------ ------------------------------NLS_COMP BINARY BINARY BINARYNLS_SORT BINARY BINARYNLS_CALENDAR GREGORIAN GREGORIANNLS_CURRENCY TL $NLS_LANGUAGE AMERICAN AMERICAN AMERICANNLS_TERRITORY TURKEY AMERICA AMERICANLS_DATE_FORMAT YYYYMMDD HH24:MI:SS DD-MON-RRNLS_TIME_FORMAT HH24:MI:SSXFF HH.MI.SSXFF AMNLS_CHARACTERSET WE8ISO8859P9NLS_ISO_CURRENCY TURKEY AMERICANLS_DATE_LANGUAGE AMERICAN AMERICANNLS_DUAL_CURRENCY YTL $NLS_RDBMS_VERSION 11.2.0.1.0NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR HH.MI.SSXFF AM TZRNLS_NCHAR_CONV_EXCP FALSE FALSE FALSENLS_LENGTH_SEMANTICS BYTE BYTE BYTENLS_TIMESTAMP_FORMAT DD/MM/RRRR HH24:MI:SSXFF DD-MON-RR HH.MI.SSXFF AMNLS_NCHAR_CHARACTERSET AL16UTF16NLS_NUMERIC_CHARACTERS ,. .,NLS_TIMESTAMP_TZ_FORMAT DD/MM/RRRR HH24:MI:SSXFF TZR DD-MON-RR HH.MI.SSXFF AM TZR20 rows selected.Elapsed: 00:00:00.04
Democracy is the recurrent suspicion that more than half of the people are right more than half of the time. – E. B. White
This entry was posted on July 21, 2010 at 19:46 and is filed under oracle. Tagged: listagg pivot nls. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Vishal Gupta said
You could following query to get same information. And it will work all Oracle versions not just 11gR2
select ndp.parameter
, max(nsp.value) Sesssion
, max(nip.value) Instance
, max(ndp.value) Database
FROM nls_session_parameters nsp
, nls_instance_parameters nip
, nls_database_parameters ndp
WHERE ndp.parameter = nsp.parameter (+)
AND ndp.parameter = nip.parameter (+)group by ndp.parameter
;
Vishal Gupta said
Or following query, if you like ANSI
select ndp.parameter
, max(nsp.value) Sesssion
, max(nip.value) Instance
, max(ndp.value) Database
FROM nls_session_parameters nsp
FULL OUTER JOIN nls_instance_parameters nip ON nip.parameter = nsp.parameter
FULL OUTER JOIN nls_database_parameters ndp ON ndp.parameter = nsp.parameter
group by ndp.parameter
;
fsengonul said
Hi Vishal,
You’re definitely right. Yours is a better solution.But I still wonder why you needed the max function. On 11g even the following query has the same result:
select ndp.parameter
, nsp.value Sesssion
, nip.value Instance
, ndp.value Database
FROM nls_session_parameters nsp
FULL OUTER JOIN nls_instance_parameters nip ON nip.parameter = nsp.parameter
FULL OUTER JOIN nls_database_parameters ndp ON ndp.parameter = nsp.parameter
order by 1 asc
Thanks a lot.
Vishal Gupta said
Hi Ferhat,
You are right, there is no need of a max in the query. I was originally writing query differently using a group by and forgot to remove the max in the SELECT list.