Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: run 2 query mysql

by davido (Cardinal)
on Mar 04, 2019 at 16:44 UTC ( #1230857=note: print w/replies, xml ) Need Help??


in reply to Re^2: run 2 query mysql
in thread run 2 query mysql

It sure can, you just have to be willing to think about it instead of copying/pasting.

{ local $dbh->{AutoCommit} = 0; # enable transactions, if possible local $dbh->{RaiseError} = 1; local $@; eval { foo(...) # do lots of work here bar(...) # including inserts baz(...) # and updates $dbh->commit; # commit the changes if we get this far }; if ($@) { warn "Transaction aborted because $@"; eval { $dbh->rollback }; } } # Note, RaiseError and AutoCommit now revert to previous state.

...just one of a number of ways to adapt the example code.


Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2019-05-23 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (142 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!