Hello, John!
I like Rose::DB very much but I wish to have one more feature. There is
a very convinient "do_transaction" method but it does not support nested
transaction.
I'd like to have "nest_transaction" method which will be the same as
"do_transaction" but will not create new transaction if one is already
started and will throw exception on error;
This code
$db->nest_transaction(sub {
$db->do('UPDATE...'); #Outer update
$db->nest_transaction(sub {
$db->do('UPDATE...'); #Inner update
});
})
will be instead of
my $udpate_sub_outer = sub {
$db->do('UPDATE...'); # Outer update
my $update_sub_inner = sub {
$db->do('UPDATE...'); # Inner update
}
if ( $db->in_transaction ) {
$update_sub_inner->();
} else {
$db->do_transaction($udpate_sub_inner) or die $db->error;
}
};
if ( $db->in_transaction ) {
$udpate_sub_outer->();
} else {
$db->do_transaction($udpate_sub_outer) or die $db->error;
}