简体   繁体   English

Perl,DBD :: Oracle和Oracle 10g的字符集问题

[英]Character set problems with Perl, DBD::Oracle and Oracle 10g

We have a problem with characters outside of the basic ASCII set appearing as upside down question marks in our Oracle 10g database. 基本ASCII集之外的字符出现问题,在我们的Oracle 10g数据库中显示为颠倒的问号。

I have the following script to load some test data. 我有以下脚本来加载一些测试数据。 The script is saved as Latin-1/ISO-8859-1 on a remote UNIX server from Komodo IDE: 该脚本在Komodo IDE的远程UNIX服务器上保存为Latin-1 / ISO-8859-1:

#!/wload/espd/app/perl/bin/perl

use strict; 
use warnings;
use Encode;
use esp_libs_db;
my $dbh = espDbConnectNew();

my $sql = q{ INSERT INTO DBUSER.test VALUES ('qwérty')};

#$sql = encode("iso-8859-1", $sql);

my $rows = $dbh->do($sql)  or Carp::croak "ERROR: PM_DB_0010:[" . $DBI::errstr . "]   Cannot run stmt:\n";;
print $rows;
$dbh->commit();
$dbh->disconnect();



sub espDbConnectNew {
    my ( $database ) = @_;    
    my %connectionStrings = &esp_libs_db::espGetConnectionStrings( $database );

    # Set Environment Variables
    $ENV{ORACLE_SID}=$connectionStrings{"SID"};
    $ENV{ORACLE_HOME}=$connectionStrings{"HOME"};
    my $dbh = DBI->connect("dbi:Oracle:SID=$connectionStrings{'SID'};HOST=$connectionStrings{'HOST'};PORT=$connectionStrings{'PID'}",
    "$connectionStrings{'USER'}","$connectionStrings{'PWD'}",
    {PrintError=>0,
    RaiseError => 0,
    AutoCommit => 0}
) or Carp::croak "ERROR: PM_DB_0003:  Cant connect to db:\n";


    return $dbh;
} #espDbConnect

The database it loads into is an Oracle 10g database with the following parameters: 它加载的数据库是一个带有以下参数的Oracle 10g数据库:

NLS_NCHAR_CHARACTERSET  AL16UTF16
NLS_LANGUAGE    ENGLISH
NLS_TERRITORY   UNITED KINGDOM
NLS_CHARACTERSET    WE8ISO8859P1

The single column on the test table is of type VARCHAR2(255). 测试表上的单个列的类型为VARCHAR2(255)。

Despite a full working day reading about these problems I don't really know what to do to solve/diagnose the exact problem. 尽管有一整天的工作日阅读这些问题,但我真的不知道如何解决/诊断确切的问题。

I've tried this both with and without using Encode to encode the SQL string before executing it. 在使用和不使用Encode对SQL字符串进行编码之前,我已经尝试了这一点。

Thanks 谢谢

How are you retrieving the data when you get the upside down question marks? 当你得到颠倒的问号时,你如何检索数据? What is the NLS_LANG environment variable on the client where you are retrieving the data? 您正在检索数据的客户端上的NLS_LANG环境变量是什么?

In SQL*Plus, can you run 在SQL * Plus中,你可以运行吗?

SELECT dump( column_name, 1013 ), column_name
  FROM DBUSER.test

and post the results? 并发布结果? The DUMP function shows what is actually stored in the database-- that will show whether the problem is in storing the accented character or whether the problem is in retrieving the accented character. DUMP函数显示实际存储在数据库中的内容 - 这将显示问题是存储重音字符还是问题在于检索重音字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM