my $sth_udt = $dbh->prepare(qq{UPDATE items set price = ? WHERE oid = ?}); while (my $val = $sth->fetchrow) { my $price = param("item_${val}_price"); $sth_udt->execute($price, $val); # You could probably just do: # $sth_udt->execute(param("item_${val}_price"), $val); }