Re: [Dbi-interbase-devel] How to close open transactions with AutoCommit = 1 in case of a failed pre
Status: Beta
Brought to you by:
edpratomo
From: Daniel R. <dan...@gm...> - 2001-07-30 17:09:32
|
hello i've created two scripts doing what you described. the first is with AutoCommit = 0, the second with AutoCommit = 1. first: create an empty db with ib console. - when you first run the script you see the error message for the failed prepare, the table is cerated and some data is inserted into it. - second run: display content of the table created before. you can find the scripts at http://ritz.dnsart.com/interbase one question: what version of dbd-interbase are you using? rgds -daniel ps: if you problem still exists and you're using an up to date version of the dbd then it's probaly a bug (a missing commit or something). in this case please send me a code example that causes the error. i then try to fix it... ----- Original Message ----- From: "Peter Köller" <pko...@me...> To: <dbi...@li...> Sent: Monday, July 30, 2001 11:32 AM Subject: [Dbi-interbase-devel] How to close open transactions with AutoCommit = 1 in case of a failed prepare? > 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 > > > _______________________________________________ > Dbi-interbase-devel mailing list > Dbi...@li... > http://lists.sourceforge.net/lists/listinfo/dbi-interbase-devel > |