Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: mod_perl ApacheDBI

by jmanning2k (Pilgrim)
on Nov 12, 2003 at 21:47 UTC ( [id://306650]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://306650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-18 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found