use DBI;
use strict;
use warnings;
my $dsn = "DBI:mysql:database=test;host=blah";
my $dbh = DBI->connect($dsn, 'root', 'abcd', {RaiseError => 1, AutoCommit => 1});
my $command = "update test set a = a + 1";
my $sth = $dbh->prepare($command);
$dbh->begin_work();
$sth->execute();
$sth->execute();
$sth->execute();
$sth->execute();
$dbh->commit();
####
use DBI;
use strict;
use warnings;
my $dsn = "DBI:mysql:database=test;host=blah";
my $dbh = DBI->connect($dsn, 'root', 'abcd', {RaiseError => 1, AutoCommit => 0});
my $command = "update test set a = a + 1";
my $sth = $dbh->prepare($command);
$dbh->begin_work();
$sth->execute();
$sth->execute();
$sth->execute();
$sth->execute();
$dbh->commit();
####
DBD::mysql::db begin_work failed: Already in a transaction at math1.pl line 10.
DBD::mysql::db begin_work failed: Already in a transaction at math1.pl line 10.