我正在使用Windows操作系统,我知道此设置存储在注册表中.问题是注册表路径从版本更改为版本,浏览虽然这一堆注册表项肯定不是一个好主意.
我可以使用SELECT USERENV(‘language’)FROM DUAL获取服务器的NLS_LANG.
这是我在解决编码问题时所做的事情. (sqlplus读取的NLS_LANG值):
原文链接:https://www.f2er.com/oracle/205641.htmlsql>/* 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]"
您必须从注册表中提取当前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
在这些时候,我转向IPython来展示一个想法:
几个查找,你就在那里!
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)