> >
> > my $sth = $dbh->do("LOCK TABLE hits IN SHARE ROW EXCLUSIVE MODE");
> > my $sth = $dbh->do("SELECT acc_hits($1)") || die $dbh->errstr;
> >
> > am I right ?
>
> You should run LOCK and SELECT inside BEGIN/END (i.e. in
> the same transaction), do you?
Yes, in DBI that translates to switching AutoCommit off, and doing an
explicit commit, (roughly)
$dbh->{AutoCommit} = 0;eval { $dbh->do (...) ...};if ($@) { // There was an error $dbh->rollback(); } else {
$dbh->commit(); }
I think you need to set RaiseError=>1 as well when connecting to the
database, to get die's inside the eval.
Adriaan