Unless you fetch to the end of the results (when $sth->fetchrow* returns false), the statement handle is active. So you can either call $sth->finish(), or call one of the selectrow_* methods (you can still use prepare_cached, just pass selectrow_* the statement handle instead of a sql statement).