# 2 # (again, just CGI.pm) use CGI 'param'; use DBI; my $dbh = DBI->connect(...) or die ...; my $id = param 'id'; my %update = map { $_ ne 'id' ? ($_ => param($_)) : () } param; my @bind = (); # First, build one large UDPATE statement # and collect the bind values while we're at it my $sql = "UPDATE mytable SET " . # Doing this from the top of my head, join(", ", # untested, but it should get the grep defined, map { # idea across if ($_ ne 'id') { push @bind, param($_); sprintf "%s = ?", $_ } else { undef } } param ) ; # And then hit the database with that UPDATE statement just once. $dbh->do($sql, undef, bind);