josh097 has asked for the wisdom of the Perl Monks concerning the following question:
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:
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.if ($input[0] ne $inputUpdate[0]) { my $dbquery eq "UPDATE table_name SET column_name=$inputUpdate[0] WHER +E column_name=$input[1]"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Best way to check which field(s) was changed
by Corion (Patriarch) on Dec 29, 2008 at 17:57 UTC | |
by josh097 (Initiate) on Dec 29, 2008 at 18:13 UTC | |
|
Re: Best way to check which field(s) was changed
by runrig (Abbot) on Dec 29, 2008 at 18:20 UTC | |
|
Re: Best way to check which field(s) was changed
by ccn (Vicar) on Dec 29, 2008 at 18:05 UTC | |
|
Re: Best way to check which field(s) was changed
by JavaFan (Canon) on Dec 29, 2008 at 18:20 UTC |