I've got a couple of methods that should be executed only in the case my DBI driver class is currently into a transaction to ensure data integrity. I'm looking to write something like this:
sub m{
my ($self , $dbh ) = @_ ;
unless( $dbh->isInTransaction()){
die "Use this only within a transaction\n" ;
}
etc ...
}
From the docs for begin_work, I understand that begin_work will set AutoCommit
to off during the time of the transaction and will set it back to 'on' on commit or rollback, but I wonder if testing for the AutoCommit
attribute value is a safe way to implement isInTransaction
.
Thanks for your help.
J.