• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1975
  • Last Modified:

Count number of rows in sys_refcursor

I want to print the number of rows gathered in sys_refcursor variable STATS.

set serveroutput on BUFFER 100000000
  P_param1_1 VARCHAR2(200);
  P_param1_2 VARCHAR2(200);
  STATS sys_refcursor;
  P_param1_1 := 'ABC';
  P_param1_2 := 'DEF';

    P_param1 => P_param1_1,
    P_param2 => P_param1_2,
  • 2
1 Solution
slightwv (䄆 Netminder) Commented:
You have to open the cursor and loop through it.  There is no cursor.count type property.
gram77Author Commented:
when refcursor has a cursor.count property then why dosen't sys_refcursor have the same?
slightwv (䄆 Netminder) Commented:
Cursors do not have a count property no matter what type they are.  If you have documentation that shows this, I would love to take a look at it.

There is a ROWCOUNT inside pl/sql that shows affected rows after some DML have been processed.

You cannot get a count from a cursor until you have opened it and processed all the rows.  This is typically done with a loop counter that is incremented as you loop through the cursor.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now