$dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; my $insert_ID = 0; eval { my $sql = "some insert query"; $sth ||= $dbh->prepare ($sql); $sth->execute (@params); $insert_ID = $dbh->{'mysql_insertid'}; $dbh->commit; # commit the changes if we get this far }; if ($@) { # And commit or rollback print STDERR "Transaction aborted because $@\n"; $dbh->rollback; # undo the incomplete changes }
In reply to Last insert ID with Transactions and Mysql by simon.proctor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |