Front page | perl.dbi.users |
Postings from August 2006
RE: AutoCommit does not work
Thread Previous
|
Thread Next
From:
Mary Anderson
Date:
August 22, 2006 10:24
Subject:
RE: AutoCommit does not work
Message ID:
200608221723.k7MHNq3p000017@diometes.ucdavis.edu
>Artem Harutyunyan wrote:
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.
Artem,
In MySQL your table must be of type INNOB for transactions to be
supported.
HTH
Mary>
Thread Previous
|
Thread Next