Well, as they always say, TIMTOWTDI ;) Personally, if you don't want to keep old scores lying around, I would always do a delete statement, then an insert to add in the new stores. IMHO, it's a bit less work (for you and the database). I mean, you could check to see if the update processed successfully, and if not, do an insert, but this requires a lot less thought ;)

You might also wish to explicitly issue a commit at the end of your script. While I haven't brushed up on the DBI documentation lately, assuming that the disconnect will do a commit for you just strikes me as a bad idea (that next rollback could be brutal. . . ). For safety sake, you might wish to add a $dbh->commit() before the disconnect.

And (just a writeup tip) I hope the connection information for MySQL is bogus. If not, I hope you change the username and password for database access before exposing your database to the world ;) Kinda related to that though, you might wish to check out How (Not) To Ask A Question by jeffa for that (not giving us your real username and password) and other good writeup tips.

Hope this was of some help :) Good luck!
MrCromeDome


In reply to Re: checking to do a inser or update by MrCromeDome
in thread checking to do a insert or update by perlinacan

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.