in reply to Best way to check which field(s) was changed
I suggest to have two hashes: %input, and %inputUpdate instead of arrays. Those hashes contain ColumnName => value pairs.
Than, assuming ID is identity column:
my %update = map {$_ => $inputUpdate{$_} } grep {$inputUpdate{$_} ne $input{$_} } keys %input; $dbh->do(<<"SQL", undef, values %update, $input{ID}); update TableName set @{[ join ', ', map {"$_ = '?'"} keys %update]} where ID = ? SQL $dbh->commit;
|
|---|