Mr Scary, Here is how I do it, and I am assuming that you have a database connection.
use strict; use diagnostics; ############################################################ # Using the \$STATEMENT varible makes it easier # for me to prepare it for 'quotes' that are needed # by SQL (MySql) and helps me resolve my variables safely. # ---------------------------------------------------------- my $STATEMENT = "UPDATE SUPPORTDESK.CONTACT_PERSON SET SALUTATION=$S +ALUTATION,FIRST_NAME=$FIRST_NAME,MIDDLE_INITIAL=$MIDDLE_INITIAL,LAST_ +NAME=$LAST_NAME,NOTES=$NOTES WHERE CONTACT_PERSON.CONTACT_PERSON_ID=$ +CONTACT_PERSON_ID"; ############################################################ # Prepare the statement for database execution. This inserts # quotes where needed # ---------------------------------------------------------- # $DBACCESS is the database connection handle '$dbh' my $COMMAND = $DBACCESS->prepare($STATEMENT); #Executed the statment. $COMMAND->execute; ############################################################ # Kill the statement handle so that you can safely # disconnect from the database. # ---------------------------------------------------------- $COMMAND->finish;
Word of caution. I use InnoDB style database tables which autocommit. Autocommitting means once you put information there, it is permanent. No rolling back, and the information is flushed to the disk. If you don't autocommit then the Statement will be more like this... my $STATEMENT = "BEGIN; UPDATE SUPPORTDESK.CONTACT_PERSON  SET   SALUTATION=$SALUTATION,FIRST_NAME=$FIRST_NAME,MIDDLE_INITIAL=$MIDDLE_INITIAL,LAST_NAME=$LAST_NAME,NOTES=$NOTES WHERE CONTACT_PERSON.CONTACT_PERSON_ID=$CONTACT_PERSON_ID; COMMIT"; I hope this helps. Kristofer Hoch

In reply to Re: best method to update mysql records over the web by krisahoch
in thread best method to update mysql records over the web by mr_scary

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.