eval { my $sth=$dbh->prepare( q{ your sql here } ); $sth->execute( ... ); # params in the parens to be inserted as above $dbh->commit; }; if($@) { $dbh->rollback; print STDERR "Bad things happened: $@"; }