Search code examples
oracle-databaseplsqlrowcount

How can I get the number of rows from a refcursor in plsql?


I have an sp that returns 3 separate ref cursors.

Customer_sp(p_musterino=>1111,p_rc1 => p_rc1, p_rc2 => p_rc2, p_rc3 => p_rc3);

I need to get the number of rows returned from the first cursor, rc1. The data of the first cursor comes from different tables joining and have a lot of columns. I do not want to write fetch stating all of them just to get the count. Is there an easy way to get the number of rows?


Solution

  • No. Oracle only knows how many rows the query will return when it has finished fetching the last row. So until you've fetched the data, you won't know how many rows there are.

    You may be able to make fetching the data easier by declaring a %rowtype variable to fetch the data into. That saves you from needing to declare dozens of local variables.