Cursor%Rowcount shows 0

Posted on 2008-11-07
Last Modified: 2013-12-19
Cursor%Rowcount shows the value Zero.
SELECT command showing output but Cursor%Rowcount shows the value Zero.
Question by:Biju1149
    LVL 9

    Expert Comment

    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.
    LVL 27

    Accepted Solution

    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


    Author Comment

    Hi sujith80

    Thanks very much for your valued reply.
    LVL 27

    Expert Comment

    Does it answer your query?

    Author Comment

     yes Sujith
    LVL 27

    Expert Comment

    Great. Please close the question.

    Author Closing Comment

    Thanks very much for the help

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
    Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
    This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
    This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now