Cursor%Rowcount shows 0

Cursor%Rowcount shows the value Zero.
SELECT command showing output but Cursor%Rowcount shows the value Zero.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

When do you invoke the Cursor%Rowcount - function? It won't bring back any value until you have fetched records, as it only shows the value of how many records have been fetched so far.
SujithData ArchitectCommented:
ROWCOUNT attribute is useful in case of bulk SELECTs.
You have to use this attribute in PL/SQL code.
You mus use the actual cursor name as in <cursor name>%rowcount.

For implicit selects there is an attribute called SQL%ROWCOUNT.

See the following example.
If it doesnt help, post the portion of your code.

SQL> declare
  2   cursor c1 is 
  3   select object_id from tbl1;
  4   type t1 is table of number index by binary_integer;
  5   l_t1 t1;
  6  begin
  7   open c1;
  8   fetch c1 bulk collect into l_t1;
  9   dbms_output.put_line('No of records from cursor is : '||c1%ROWCOUNT);
 10   close c1;
 12   select object_id bulk collect into l_t1
 13   from tbl1;
 15   dbms_output.put_line('No of records fetched is : '||SQL%ROWCOUNT);
 16  end;
 17  /
No of records from cursor is : 10
No of records fetched is : 10
PL/SQL procedure successfully completed.

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Biju1149Author Commented:
Hi sujith80

Thanks very much for your valued reply.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SujithData ArchitectCommented:
Does it answer your query?
Biju1149Author Commented:
 yes Sujith
SujithData ArchitectCommented:
Great. Please close the question.
Biju1149Author Commented:
Thanks very much for the help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

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.