如何检查客户端的NLS_LANG? [英] How do I check the NLS_LANG of the client?

查看:372
本文介绍了如何检查客户端的NLS_LANG?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows操作系统上工作,我知道这个设置存储在注册表中。问题是注册表路径从版本到版本的改变,浏览虽然这堆注册表项是绝对不是一个好主意。



我可以得到 SELECT USERENV('language')FROM DUAL 的服务器的C> NLS_LANG 。



我想将其与客户端设置进行比较,如果它们不匹配,则会显示警告,就像Pl / Sql Developer一样。

解决方案

这是我解决编码问题时我做的。 (由sqlplus读取的NLS_LANG值):

  SQL> / *这是一个黑客。我不知道为什么它的工作。但它是!* / 
SQL> @ [%NLS_LANG%]
SP2-0310:无法打开文件[NORWEGIAN_NORWAY.WE8MSWIN1252]
pre>

必须从注册表中提取当前ORACLE_HOME中的NLS_LANG值。
所有客户端工具(sqlplus,sqlldr,exp,imp,oci等)从注册表
读取此值,并确定是否应发生任何字符转码。



ORACLE_HOME和注册表部分:

  C:\> dir / s / b oracle.key 
C:\Oracle10\BIN\oracle.key

C:\> type C:\Oracle10\BIN\ oracle.key
SOFTWARE\ORACLE\KEY_OraClient10204_Home





$ b b

在这样的时候,我转向IPython来展示一个想法:



几次查找,你就在那里! p>

 在[36]:OHOMES_INSTALLED =!其中oci.dll 

在[37]:OHOMES_INSTALLED
Out [37]:
['C:\\Oracle10\\BIN\\oci.dll',
'C:\\oraclexe\\ app\\\ororacle\\product\\11.2.0\\server\\bin\\oci.dll']

在[38]: ORACLE_HOME = os.path.dirname(OHOMES_INSTALLED [0])

在[39]:ORACLE_HOME
Out [39]:'C:\\Oracle10\\BIN'

在[40]:f = open(os.path.join(ORACLE_HOME,oracle.key))

在[41]:SECTION = f.read ()

在[42]:SECTION
Out [42]:'SOFTWARE\\ORACLE\\KEY_OraClient10204_Home\\\
'

[43]:from _winreg import *

在[44]:aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)

在[46]:aKey = OpenKey(aReg, strip())

In [47]:val = QueryValueEx(aKey,NLS_LANG)

在[48]:print val
(u'NORWEGIAN_NORWAY .WE8MSWIN1252',1)


I'm working on Windows OS, I know that this setting is stored in the registry. The problem is that the registry path changes from version to version, browsing though that bunch of registry keys is definitly not a good idea.

I can get the NLS_LANG of the server with SELECT USERENV ('language') FROM DUAL.

I'd like to compare that with the client setting and show a warning when they don't match, just like Pl/Sql Developer does.

解决方案

This is what I do when I troubleshoot encoding-issues. (The NLS_LANG value read by sqlplus):

SQL>/* It's a hack. I don't know why it works. But it does!*/
SQL>@[%NLS_LANG%]
SP2-0310: unable to open file "[NORWEGIAN_NORWAY.WE8MSWIN1252]" 

You will have to extract the NLS_LANG value in current ORACLE_HOME from the registry. All client-side tools (sqlplus, sqlldr, exp, imp, oci, etc...) read this value from registry and determine if any character transcoding should occur.

ORACLE_HOME and registry section:

C:\>dir /s/b oracle.key
C:\Oracle10\BIN\oracle.key

C:\>type C:\Oracle10\BIN\oracle.key
SOFTWARE\ORACLE\KEY_OraClient10204_Home


In times like these I turn to IPython to demonstrate an idea:

A couple of lookups and you are there!

In [36]: OHOMES_INSTALLED = !where oci.dll

In [37]: OHOMES_INSTALLED
Out[37]:
['C:\\Oracle10\\BIN\\oci.dll',
'C:\\oraclexe\\app\\oracle\\product\\11.2.0\\server\\bin\\oci.dll']

In [38]: ORACLE_HOME = os.path.dirname(OHOMES_INSTALLED[0])

In [39]: ORACLE_HOME
Out[39]: 'C:\\Oracle10\\BIN'

In [40]: f = open(os.path.join(ORACLE_HOME, "oracle.key"))

In [41]: SECTION = f.read()

In [42]: SECTION
Out[42]: 'SOFTWARE\\ORACLE\\KEY_OraClient10204_Home\n'

In [43]: from _winreg import *

In [44]: aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)

In [46]: aKey = OpenKey(aReg,SECTION.strip())

In [47]: val = QueryValueEx(aKey, "NLS_LANG")

In [48]: print val
(u'NORWEGIAN_NORWAY.WE8MSWIN1252', 1)

这篇关于如何检查客户端的NLS_LANG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆