local $dbh->{AutoCommit} = 0; local $dbh->{RaiseError} = 1; # You can RaiseError and eval the transaction # or you can check $sth->err each time and rollback eval { ##Do your read and write here $dbh->commit; }; if ($@) { warn "append failed $@"; $dbh->rollback; }