Subject: | AutoCommit, begin_work documentation/code conflict |
According to http://search.cpan.org/~ishigaki/DBD-SQLite-1.42/lib/DBD/SQLite.pm#Transactions , the default, and preferred, behavior is $dbh->{AutoCommit} = 1. According to this documentation, you can start a transaction to temporarily disable AutoCommit with $dbh->begin_work, and gives an example of doing so.
The actual behavior, however, throws an error:
my $dbs = $dbh->prepare('SELECT...');
$dbs->execute;
...
$dbh->begin_work;
DBD::SQLite::db begin_work failed: Already in a transaction at script.pl line XYZ
So to get around this, I thought that may be the SELECT statements were causing a transaction to be started. I tried,
my $dbs = $dbh->prepare('SELECT...');
$dbs->execute;
...
$dbh->commit;
$dbh->begin_work;
DBD::SQLite::db begin_work failed: Already in a transaction at script.pl line XYZ
As you can see, ->begin_work does _not_ suspend AutoCommit (at least, not silently) to start a new transaction. I suspect (but haven't tested) that it doesn't start a transaction encompassing more than the single next statement.