my $sth = $dbh->prepare("select name from file_table where "); my $upd_sth = $dbh->prepare("update file_table set timestamp = ? where name = ?"); while(my $d = $sth->fetch) { # do the upload, etc; # if all is well: $sth_upd->execute(time, $d->[0]); }