Jie Zhang wrote:
Tom and Martin,

Thank you both!
It is a bit counter intuitive.

If by that you mean that you expected disconnect with a commit to rollback the changes then I agree. We had an Oracle ODBC driver which used oci which did this and ended up changing it to NOT commit on disconnect because we (and more importantly our customers) believed it was just too dangerous.

Off the top of my head I can't remember how this was achieved in
OCI but it was.

Martin

Tom Schindl wrote:

Well I was already familiar with this behaviour because it's the same
with JDBC-Drivers.

Tom

Martin J. Evans wrote:
On 07-Apr-2006 Jie Zhang wrote:

Hi,

If I initiate a connection using autocommit=0 in DBI and I don't do a explicit connection->commit(), should transactions automatically commit after I do an explicit connection->disconnect()? I was expecting an automatica rollback. But the testing result is just the opposite.

For example:
my $databaseHandle = DBI->connect( "", "[EMAIL PROTECTED]", "$pass", {AutoCommit => 0}, "Oracle" )
deleteRecord;
$databaseHandle->disconnect();

Should the delete query be commited?

thanks,

Jie

According to the DBI docs:

          The transaction behaviour of the "disconnect" method
          is, sadly, undefined.  Some database systems (such as
          Oracle and Ingres) will automatically commit any out-
          standing changes, but others (such as Informix) will
          rollback any outstanding changes.  Applications not
          using "AutoCommit" should explicitly call "commit" or
          "rollback" before calling "disconnect".

I was a bit surprised to see the comment on Oracle automatically committing. I
believe there is a way to stop this happening at the oci level.

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com








Reply via email to