Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2010
    Posts
    9

    Unanswered: How to take the Cursor count into a variable

    My aim is to take the cursor count into reccount variable.


    Code:
    =======

    DECLARE reccount NUMBER;
    EmpObjid NUMBER;
    EmpName NVARCHAR2(40);




    CURSOR EMPCursor IS
    select objid,name from table_emp where id='732' ;

    BEGIN

    OPEN EMPCursor ;
    LOOP
    FETCH windowCursor INTO EmpObjid , EmpName;
    EXIT WHEN windowCursor%NOTFOUND;
    ----------------

    END LOOP;
    CLOSE EMPCursor ;
    END;
    /

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Have you tried using %ROWCOUNT with the cursor and this returns the number of rows.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Apr 2010
    Posts
    9
    i want to get the count to a variable

  4. #4
    Join Date
    Apr 2010
    Posts
    9
    reccount=EmpCursor%NOTFOUND;
    After keeping the above line it is giving the following problem

    Error at line 1
    ORA-06550: line 18, column 15:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:

    := . ( @ % ;
    ORA-06550: line 20, column 4:
    PLS-00103: Encountered the symbol "DBMS_OUTPUT"
    ORA-06550: line 20, column 110:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:

    . ( , * % & - + / at mod remainder rem <an identifier>
    <a double-quoted delimited-identifier> <an exponent (**)> as
    from into || multiset bulk
    ORA-06550: line 27, column 5:
    PLS-00103: Encounte

  5. #5
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Just before you close the cursor:

    reccount := EmpCursor&#37;ROWCOUNT;

    The ROWCOUNT in this type of cursor keeps track of the number of records read so far.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

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