PHP 和 Oracle - oci_connect() ORA-12705:无法访问 NLS 数据文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6549251/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP & Oracle - oci_connect() ORA-12705: Cannot access NLS data files
提问by Nick
We've been using Oracle on our server for years, but someone from IT removed it yesterday without clear warning and it's really thrown our systems!
我们多年来一直在我们的服务器上使用 Oracle,但是昨天 IT 部门的某个人在没有明确警告的情况下删除了它,它真的抛出了我们的系统!
I've acted on the advice from cwallenpoole (thank you!) and have made good progress, and PHP is now at least including the oracle functions (ie oci_connect) but I am now experiencing another error message:
我已经按照 cwallenpoole 的建议采取了行动(谢谢!)并取得了良好的进展,PHP 现在至少包含了 oracle 函数(即 oci_connect),但我现在遇到了另一条错误消息:
"Warning: oci_connect() [function.oci-connect]: ORA-12705: Cannot access NLS data files or invalid environment"
“警告:oci_connect() [function.oci-connect]:ORA-12705:无法访问 NLS 数据文件或无效环境”
We have ensured the tnsnames.ora etc files are in the correct place, but still having no joy :(
我们已经确保 tnsnames.ora 等文件在正确的位置,但仍然没有快乐:(
thank you
谢谢你
回答by cwallenpoole
Ok. This is my personal nightmare. I seriously wake up in the middle of the night... or I don't, but I have spent days on this problem.
好的。这是我个人的噩梦。我真的在半夜醒来......或者我没有,但我已经在这个问题上花了几天时间。
So, this is what worked for me:
所以,这对我有用:
- Do you have Oracle Instant Client? If not get it.
- Do you have the Oracle SDK? If not get it.
- Unzip instantclient.
- Unzip the SDK into a sub-directory
- Add ORACLE_HOME as an exported command line variable ($ORACLE_HOME in *nix, %ORACLE_HOME% in win). Have it point to the fully-qualified path to the above instantclient folder.
- Create ORACLE_BIN and have it point to the SDK.
- Add ORACLE_HOME to your PATH.
- Restart Apache...
- 你有Oracle Instant Client吗?如果没有得到。
- 你有 Oracle SDK吗?如果没有得到。
- 解压缩即时客户端。
- 将 SDK 解压到子目录
- 添加 ORACLE_HOME 作为导出的命令行变量(*nix 中的 $ORACLE_HOME,win 中的 %ORACLE_HOME%)。让它指向上述 Instantclient 文件夹的完全限定路径。
- 创建 ORACLE_BIN 并将其指向 SDK。
- 将 ORACLE_HOME 添加到您的 PATH。
- 重启阿帕奇...
So... that is what I generally do... And generally it works... Mostly...
所以......这就是我通常做的......而且通常它有效......主要......
I think that realistically all I can say is Good Luck and Godspeed.
我认为实际上我只能说祝你好运和神速。
回答by Ed Manet
The only way I could get PHP to connect to Oracle was using the Zend Framework.
我可以让 PHP 连接到 Oracle 的唯一方法是使用 Zend 框架。
回答by ?????
Follow this procedure to set the NLS_LANG environment variable for Oracle databases. To set the NLS_LANG environment variable for Oracle databases Determine the NLS_LANG value. In the data warehouse database, run the command
按照此过程为 Oracle 数据库设置 NLS_LANG 环境变量。为 Oracle 数据库设置 NLS_LANG 环境变量 确定 NLS_LANG 值。在数据仓库数据库中,运行命令
SELECT * FROM V$NLS_PARAMETERS
SELECT * FROM V$NLS_PARAMETERS
Make a note of the NLS_LANG value, which is in the format [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]. For example: American_America.UTF8
记下 NLS_LANG 值,其格式为 [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]。例如:American_America.UTF8
For Windows: Navigate to Control Panel > System and click the Advanced tab. Click Environment Variables.
对于 Windows:导航到控制面板 > 系统,然后单击高级选项卡。单击环境变量。
In System variables section, click New. In the Variable Name field, enter NLS_LANG. In the Variable Value field, enter the NLS_LANG value that was returned in Step 1. The format for the NLS_LANG value should be [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]. For example: American_America.UTF8. For UNIX, set the variable as shown below: setenv NLS_LANG
在系统变量部分,单击新建。在变量名称字段中,输入 NLS_LANG。在变量值字段中,输入在步骤 1 中返回的 NLS_LANG 值。NLS_LANG 值的格式应为 [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]。例如:American_America.UTF8。对于 UNIX,如下设置变量: setenv NLS_LANG
For example: setenv NLS_LANG American_America.UTF8. If your data is 7-bit or 8-bit ASCII and the Informatica Server is running on UNIX, then set NLS_LANG _.WE8ISO8859P1 CAUTION: Make sure you set the NLS_LANG variable correctly, as stated in this procedure, or your data will not display correctly.
例如:setenv NLS_LANG American_America.UTF8。如果您的数据是 7 位或 8 位 ASCII 并且 Informatica Server 在 UNIX 上运行,则设置 NLS_LANG _.WE8ISO8859P1 注意:确保按照此过程中所述正确设置 NLS_LANG 变量,否则您的数据将不会显示正确。
Reboot the machine after creating the variable.
创建变量后重新启动机器。