将多字节字符从 perl 插入到 oracle 时遇到 ORA-01461
我有一个 perl 脚本,它将文本文件中的记录插入到我们的数据库中。每当记录具有多字节字符(如“RODR_Í_GUEZ”)时。我收到错误 ORA-01461,但是我距离从 varchar2 切换到长
设置的 4000 个字符还差得很远:
$ENV{NLS_CHARACTERSET} = 'AL32UTF8';
在连接之前似乎没有帮助。
使用java客户端(SQuirreL SQL)并手动编写INSERT INTO语句可以很好地插入记录,所以我确信这不是数据库的配置方式。
有什么想法吗?
I have a perl script that is inserting records from a text file into our database. Whenever the record has a multibyte character like "RODR_Í_GUEZ". I receive the error ORA-01461, however i'm nowhere near the 4000 characters to switch from varchar2 to long
setting:
$ENV{NLS_CHARACTERSET} = 'AL32UTF8';
before connecting doesn't seem to help.
Using a java client (SQuirreL SQL) and manually writing the INSERT INTO statement inserts the record just fine, so i'm sure it's not how the database is configured.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想要设置 NLS_LANG 环境变量。对于 Unix-ish 系统,$ORACLE_HOME/server/bin 中提供了一个名为 nls_lang.sh 的脚本,用于根据 LANG 环境变量为您的系统输出合理的值。
例如,对于我的系统 (LANG=en_GB.UTF-8),等效的 Oracle 设置是
更多信息: http://forums.oracle.com/forums/thread.jspa?threadID=381531
Sergiusz 的帖子几乎说了您需要知道的所有内容:我只是补充说 Perl DBD::Oracle 驱动程序是基于 OCI,而纯 Java JDBC 驱动程序不是基于 OCI,因此它们在同一环境中的工作方式不同。
You probably want to set the NLS_LANG environment variable. For Unix-ish systems, there is a script supplied in $ORACLE_HOME/server/bin called
nls_lang.sh
to output a reasonable value for your system, based on the LANG environment variable.e.g. for my system (LANG=en_GB.UTF-8) the equivalent Oracle setting is
More info: http://forums.oracle.com/forums/thread.jspa?threadID=381531
Sergiusz's post there says practically all you need to know: I'll just add that the Perl DBD::Oracle driver is OCI-based, and the pure-Java JDBC driver isn't, hence they work differently in the same environment.