[Dbi-interbase-devel] How to close open transactions with AutoCommit = 1 in case of a failed prepare
Status: Beta
Brought to you by:
edpratomo
From: <pko...@me...> - 2001-07-30 09:31:01
|
Hello! Is there a good portable solution for doing the following: 1. select something 2. if prepare failed (e. g. the database tables don't exist) then goto 3. else goto 4. 3. create database tables 4. execute statement I run into the problem, that create tables fails because of open transactions. Even disconnect fails in Step 3. "DBD::InterBase::db disconnect failed: Unsuccessful execution caused by system er ror that does not preclude successful execution of subsequent statements -cannot disconnect database with open transactions (1 active)" I use connect with AutoCommit set to true. Would the following be a good portable solution for DBD::InterBase and other database drivers, too??? $db->{AutoCommit} = 0; $st = $db->prepare($sql); if (!$st) { print "error ..."; $db->rollback(); return; } $st->execute(); if (!$st) { print "error ..."; $db->rollback(); return; } ... $db->commit(); With other DBD drivers, e. g. ODBC I had no problem with creating database tables after a prepare failed, even if AutoCommit was set to true. There was no error message about open transactions. I worry about database drivers which don't support transactions. Any suggestions? Regards, Peter |