in reply to Re: mod_perl ApacheDBI
in thread mod_perl ApacheDBI

The local must go outside the eval block. Otherwise, AutoCommit will be restored when leaving the eval block. When AutoCommit changes from off to on, DBI says that there will be a commit. This includes when the eval block is terminated with an exception. The automatic commit defeats the whole purpose of wrapping it in an eval and checking for a rollback.

It is a bad idea to set the AutoCommit back to 1 at the end. Leaving the enclosing scope with reset it in any case. Also, it assumes that the AutoCommit defaults to on. One of the nice things about the transaction structure is that it works right regardless of the initial setting of AutoCommit.