【发布时间】:2013-12-19 10:17:16
【问题描述】:
我在阅读 MySQL 时遇到了一些奇怪的错误,我的代码是这样的:
my $sql = <<"sqleof";
select t1.name t1_name, t2.name t2_name from t2
inner join t1 using(Id)
where t2.Id in (select Id from t3 where t3Id='$id')
sqleof
#here $dbh had connected correctly and done some query before this; $sql can execute pretty well on MySQL command line and return me some records.
my $execute = $dbh->prepare($sql);
$execute->execute or die "Error: $DBI::errstr\n";
my @client = $execute->fetchrow_array() or die "Error: $DBI::errstr\n";
#here I got error saying: DBD::ODBC::st fetchrow_array failed: Unable to fetch information about the error
有什么问题?
大家好,很抱歉打扰您。我找到了原因。这是一个低级别的错误,因为我使用了多个 $dbh 并且我弄错了执行名称。
my $execute_A = $dbh->prepare($sql);
$execute_A->execute or die "Error: $DBI::errstr\n";
my @client = $execute_B->fetchrow_array() #$execute_B here when I copied lines and modified.
您的帮助对我来说非常重要。谢谢大家。
【问题讨论】:
-
您已标记
mysql并且错误提示您将它与 ODBC 一起使用,这是非常不寻常的设置。 -
我使用 Windows ODBC 数据源管理员创建了 DSN,并且 DSN 使用 MySQL ODBC 连接器连接远程数据库。你的 cmets 对我很有价值。