Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Catching DBI (or other) errors

by duckyd (Hermit)
on Mar 08, 2006 at 16:32 UTC ( #535207=note: print w/replies, xml ) Need Help??


in reply to Re: Catching DBI (or other) errors
in thread Catching DBI (or other) errors

If I were going to do something like this, I'd probably do something more like:
$query->execute and $sql_stage++; $query2->execute and $sql_stage++;
etc.

Replies are listed 'Best First'.
Re^3: Catching DBI (or other) errors
by Crackers2 (Parson) on Mar 08, 2006 at 18:20 UTC

    That would execute all queries even if one of them failed though. And if after your code finishes, $sql_stage is 1, you still don't know whether it was $query or $query2 that failed. Now add 3 or 4 more queries to that list and the $sql_stage variable becomes practically useless for anything except comparing to the total number of queries.

      But wrapped in an eval and combined with RaiseError, it would stop counting at the point where your query goes wrong.

      It is a bit annoying in that you have to count your queries to know which went wrong, but there may be one or two specific action points: if queries 1-4 succeeded, but 5-8 failed do X, otherwise do Y.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2023-02-05 10:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?