本文介绍了在启用了AutoCommit的情况下,Perl DBD :: ODBC回滚无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个类似下面的方块。因此,我们关闭了自动提交功能,然后执行提交/回滚。现在在回滚行上,我们失败了,说回滚在启用AutoCommit时无效。由于AutoCommit确实已被begin_work禁用,这怎么可能发生。这个问题已经存在很长时间了,并且突然发生了。

I am currently having a block like below. So with this we set autocommit off and and do a commit/rollback. Now at the rollback line , we are getting a failure saying that "rollback ineffective with AutoCommit enabled at" . How could this happen since AutoCommit was indeed disabled by the begin_work. This problem was not there for a long time and it is suddenly occuring.

在进一步调查中,我发现update_sql1创建了一个#temp表,并且update_sql2,update_sql3,update_sql4查询相同的#temp表,并且对象名称无效'#temp'错误。立即控制流到if($ @),其中$ dbh-> {AutoCommit}设置为1。首先,当update_sql1确实成功时,它对于为什么update_sql2及更高版本没有找到对象#temp感到非常困惑。

On investigating further , i found that the update_sql1 created a #temp table , and update_sql2,update_sql3,update_sql4 query the same #temp table, and are failing with Invalid object name '#temp' error. Immediately control flows to if($@) where $dbh->{AutoCommit} is set to 1. First of all its really wierd as to why update_sql2 and onwards count not find object #temp , when update_sql1 was indeed successful.

任何指针吗?

====

$ dbh-> db_Main()-> begin_work;

$dbh->db_Main()->begin_work;

eval {

 $dbh->do($update_sql1);
 $dbh->do($update_sql2);
 $dbh->do($update_sql3);
 $dbh->do($update_sql4);
 $dbh->commit;
 1;
}

if ($@) {
 $logger->info("inside catch");
 $logger->info("autocommit is $dbh->{AutoCommit}");
 $dbh->rollback;

}

===

这是完整的错误消息

Issuing rollback() due to DESTROY without explicit disconnect() of DBD::ODBC::db handle ..
rollback ineffective with AutoCommit enabled ...


推荐答案

在自动提交下,开始开始一个事务,该事务将自动提交。您必须关闭自动提交才能进行交易。

Under autocommit, the begin starts a transaction, which is automatically committed. You have to turn off AutoCommit to get a transaction.

这篇关于在启用了AutoCommit的情况下,Perl DBD :: ODBC回滚无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 05:25