【发布时间】:2011-09-21 05:48:12
【问题描述】:
我正在尝试以简化形式从事务中调用存储过程:
my $dbh= DBI->connect(............ );
my $sth = $dbh->prepare("call sp_get_workitems (1,1)");
$dbh->begin_work or die $dbh->errstr;
$sth->execute();
my ($result)= $sth->fetchrow_array();
$dbh->commit;
这会产生以下错误:
DBD driver has not implemented the AutoCommit attribute
如果我将 begin_work 语句替换为 $dbh->{'AutoCommit'} = 0;(在准备之前或之后),我会收到以下错误:
DBD::mysql::db commit failed: Commands out of sync; you can't run this command now
如果我用一个简单的 select 语句替换存储过程调用,一切正常。
存储过程包括许多更新,并以 select 语句结束。 当然,如果我可以在过程中处理事务会更容易,如果发生回滚,我需要执行一些 perl 代码。
我在 Windows 7 上使用 ActivePerl 和一个运行 Centos 并安装了 DBI 1.616 的亚马逊云实例,这两种情况都会发生。
这应该可行还是有解决办法?
谢谢
【问题讨论】:
标签: mysql perl stored-procedures dbi autocommit