Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello Monks

I have a small Perl script that parses a csv file, builds a hash and then, depenging on certain things, inserts some/all of the data into a MySQL table.
I have a unique, multi-column index, on the SQL table because I know the end user will run this script over the same data multiple times and I need to make sure we don't get multiple inserts of the same data

My problem is that, although this all works fine, the message sent back to the end user, from the script, is something like:

DBD::mysql::st execute failed: Duplicate entry '167423-192.168.160.153-b8:12:xx:yy:zc-2012-11-10 11:21:43' for key 'idx_unique_session

While this is fine for me, the end user won't have a clue what is going on!
Does anyone have any tricks on how to trap this error, compare it and if true replace it with a user friendly message e.g
"Duplicate data inserted, have you processed this file already" etc.
Thanks


In reply to Custom DBD error message by packetstormer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found