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

Thread: %rowcount problem

  1. #1
    Join Date
    Sep 2004
    Posts
    5

    Angry %rowcount problem

    hi friends

    The below procedure is exeecuting properly and displaying 37 records from SQLPLUS.
    But the problem is The %rowcount in the procedure is showing only 0(Zero).
    can u please help why it is returning 0 instead of 37 .

    PROCEDURE p_region(chFlag VARCHAR2 DEFAULT 'C',norecords out number,
    pc_Region IN OUT pkg_fe_base_dw.rc_datawindow ) IS
    BEGIN
    -- v_count := 0;
    OPEN pc_Region FOR
    SELECT rd_dv_cd,
    rd_rg_cd,
    rd_rg_sdesc,
    rd_rg_ldesc,
    nvl(ud_user_name,rd_created_by) rd_created_by,
    rd_created_dt,
    rd_end_dt, chFlag
    FROM rtl_region_def a, rtl_user_Def z
    WHERE ((chFlag='C' AND rd_end_dt IS NULL) OR (chFlag='H'))
    AND a.rd_created_By = z.ud_user_id (+)
    AND nvl(ud_most_recent_flag,'Y')='Y'
    ORDER BY rd_rg_cd;
    norecords := pc_region%rowcount;
    --norecords := 1000;
    dbms_output.put_line('no of records:-'|| pc_region%rowcount);
    --If pc_region%rowcount = 0 then
    --dbms_output.PUT_LINE(pc_region%rowcount);
    --else
    --bms_output.PUT_LINE('No Records to fetch');
    --null;
    --end if;
    END;
    END;
    /


    Thanks in advance.
    preethamnorecords := pc_region%rowcount; 14 ariel

  2. #2
    Join Date
    Jul 2000
    Posts
    296
    This procedure just opens the cursor and does not fetch any record. The%rowcount attribute shows the number of records fetched from the cursor. After opening the cursor and before fetching records it is 0.

  3. #3
    Join Date
    Sep 2004
    Posts
    5
    hi
    then how can i get the no of records with this procedure.
    Regards
    suresh

  4. #4
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    As akkerend rightly pointed out, you need to fetch from the cursor to get the rowcount. You could try something like this:

    declare
    a varchar2(1) := null;
    cursor c is
    select * from dual;
    BEGIN
    open c;
    dbms_output.put_line('no of records before fetch statement: '|| c%rowcount);
    fetch c into a;
    dbms_output.put_line('no of records after fetch statement: '|| c%rowcount);
    END;
    Cheers!
    OraKid.

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