$dbh->{RaiseError} = 1; # if not already my $sql = "UPDATE $table SET X = ? WHERE Y = ?"; my $sth = $dbh->prepare( $sql ); eval { foreach my $d ( @data ) { $sth->execute( $d->[0], $d->[1] ); } }; if ( $@ ) { print "Caught error: $@\nRolling back.\n"; $dbh->rollback; } else { $dbh->commit; }