Help for this page

Select Code to Download


  1. or download this
    eval {
       local $dbh->{AutoCommit} = 0;
    };
    $self->{_can_do_transactions} = $@ ? 0 : 1;
    
  2. or download this
    $self->{_can_do_transactions} = eval {
        local $dbh->{AutoCommit} = 0;
        1
    };
    
  3. or download this
    $self->{_can_do_transactions} = eval {
        $dbh->begin_work();
        $dbh->rollback()
    };
    
  4. or download this
    my $in_trans = eval { $dbh->begin_work() };
    if (!eval {
    ...
       eval { $dbh->rollback() } if $in_trans;
       die $msg;
    }
    
  5. or download this
    use Sub::ScopeFinalizer qw( scope_finalizer );
    
    ...
       $pending_rollback->disable();
       $dbh->commit() if $in_trans;
    }
    
  6. or download this
    BEGIN {
       package TransactionMaybe;
    ...
       code_that_touches_db();
       $transaction->commit();
    }