$sth = $dbh->prepare('select oid,* from timeclock where end_stamp is null and username=?') or die "prepare: $DBI::errstr"; # for each username { $sth->execute($username) or die "execute: $DBI::errstr"; # now do whatever with $sth->fetchrow # }