Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Database Error Handling

by mje (Curate)
on Aug 12, 2013 at 16:45 UTC ( #1049145=note: print w/replies, xml ) Need Help??


in reply to Database Error Handling

You'll save yourself a lot of code writing if you simply enable RaiseError (see the DBI pod) on your DBI handle.

If your connection fails in the above code it prints an error and falls through into code which uses your $dbh.

You test !$dbh then $dbh separately but one is the opposite of the other so two if tests are not required.

ChopBlanks has nothing to do with inserts so that line is redundant.

You can test the return of the execute on line 25 to see if the insert inserted any rows as it is not an error to insert no rows.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049145]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2017-08-19 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (311 votes). Check out past polls.

    Notices?