... $sth->execute($objid); my @rows = @{$sth->fetchall_arrayref()}; $sth->finish(); foreach $row (@rows) { ...