in reply to mod_perl ApacheDBI

I find the use of local a little curious. I think this may work if you put the first local statement inside the eval block instead of before the eval block. See Temporary Values via local()

You should not put local $dbh->{AutoCommit} = 0 after the block. If you have a local inside the eval block, then just closing the block and letting it expire is enough.

~J

Replies are listed 'Best First'.
Re: Re: mod_perl ApacheDBI
by iburrell (Chaplain) on Nov 12, 2003 at 23:50 UTC
    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.