DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Row Count

  1. #1
    Join Date
    Jan 2001
    Posts
    515
    How do I count how many rows are in a ref cursor?

  2. #2
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Set a count variable or before exit do cursor%rowcount

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  3. #3
    Join Date
    Jan 2001
    Posts
    515

    I don't think that will work

    to add a count variable would change my query, which I don't want to do and you can't exit with cursor%rowcount. It doesn't work for a ref cursor.

  4. #4
    Join Date
    Mar 2001
    Posts
    314
    Getting the number of rows in a ref cursor is not possible AFAIK. This is because of the fact that, when the ref cursor resultset is passed back to the calling app, there is no guarantee that all the rows of the resultset have been returned.

    The only way would be to process the rows one by one and keep a count :(

    Please correct me if I am wrong!


    -amar

  5. #5
    Join Date
    Feb 2001
    Posts
    27
    Try using SQLCA.SQLERRD(2). The value of this field is set to how many rows where selected. Here is a paste from an Oracle help.

    For INSERT, UPDATE, DELETE, and SELECT INTO statements, sqlca.sqlerrd[2] records the number of rows processed. For FETCH statements, it records the cumulative sum of rows processed.

    I know how to use this field when writing programs such as Cobol or C++ but I have not been able to figure out how to use it in PL/SQL.

    Here is the link to the page I found:

    http://otn.oracle.com/docs/products/...08arr.htm#5621


  6. #6
    Join Date
    Mar 2001
    Posts
    314
    SQLCA.* is a Pro*C/C++ or Pro*Cobol feature I think

    -amar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width