You have tried to use a repackaged cursor as a source for another SELECT statement.
Use the INTO TABLE clause of the SELECT - SQL statement instead.