develooper Front page | perl.dbi.users | Postings from August 2006

AutoCommit does not work

Thread Previous | Thread Next
From:
Artem Harutyunyan
Date:
August 22, 2006 02:54
Subject:
AutoCommit does not work
Message ID:
7f3529140608220254p14cde1e7tbfab179d25e863c7@mail.gmail.com
Hi,

Consider, please,  the following piece of code:
_________________________________________________________________________________
        my $dbh = DBI->connect($dsn, $user, $pass, {RaiseError =>
1,PrintError =>1});

         $dbh->{'AutoCommit'} = 0;

my $sth = $dbh->prepare(q{INSERT INTO TRANSACTION(toGroup, fromGroup,
amount) VALUES(?,?,?)});
   eval{
   $sth->execute("kuku","DADDY","3.14");
   print "Going to sleep...\n\n\n";
   sleep (60);
   };
   if ($@) {
   print "Error !!!\n\n";
   $dbh->rollback();
   exit(-2);
   }

   $dbh->commit();

_________________________________________________________________________________

It connects to the database, turns AutoCommit off, prepares the statement,
executes it, waits for 60 seconds and commits the statement.
Although I do not get any errors, it does not work as I expect. The problem
is that I can see the new entry inside the table before $dbh->commit() is
called  from the code. The same problem appears also when $dbh->begin_work
is used.

The underlying database is mySQL version 5.0.24 and the version of DBI is
1.50.

Could you please, give any hints how to debug the problem ?
Thanks in advance,
Artem.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About