my $sql = <prepare($sql); $sth->execute; my $employee_count_row = $sth->fetchrow_hashref; $sth->finish; print "NO RECORDS FOUND" unless $auth_row->{'ROWCOUNT'} > 0; ...fire the second SQL if ROWCOUNT > 0