I have a ASP file with using perlscript. It has one form with 8 fields. After the user fills them in, they are inserted into a database. Afterwards they can either do nothing, update, or delete the entry. What I want to know is what is the best or most efficient way to check which fields where changed so that I can update the database.

I have all of the original entries in an array "@input" and the new entries (whether changed or not) in another array "@inputUpdate".

Now how can I compare these two in order to have the most 'accurate' sql query?

I was thinking of going through each field and comparing the one at a time like:

if ($input[0] ne $inputUpdate[0]) { my $dbquery eq "UPDATE table_name SET column_name=$inputUpdate[0] WHER +E column_name=$input[1]"; }
Or something like that (for some reason it didn't let me put the equals sign in the code instead of "eq"). But the problem is that I don't know which fields or how many of them will be changed.

In reply to Best way to check which field(s) was changed by josh097

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.