http://www.perlmonks.org?node_id=1230852


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

cant be archived without module Try::Tiny

Replies are listed 'Best First'.
Re^3: run 2 query mysql
by davido (Cardinal) on Mar 04, 2019 at 16:44 UTC

    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

Re^3: run 2 query mysql
by marto (Cardinal) on Mar 04, 2019 at 16:04 UTC

    That particular example uses Try::Tiny, the dependencies of which are all core.