有一个游标,里面存了一些数据(未知的)。
我想知道这些数据中满足条件的数据的行数,这需要如何处理。
举个例子:
tableA
id      name
1       a
2       a
3       b
4       c
cursor v_cur is select  * from tableA我如何从游标中找到name=‘a’的行数

解决方案 »

  1.   

    OPER@tl>select * from test;       AAA BBB
    ---------- ----------
             1 a
             2 b
             3 c
             1 abcOPER@tl>declare
      2  cursor v_cur is select * from test where aaa=1;
      3  v_cnt number;
      4  begin
      5  for rec in v_cur loop
      6  v_cnt:=v_cur%rowcount;
      7  end loop;
      8  dbms_output.put_line('count aaa is:'||v_cnt);
      9  end;
     10  /
    count aaa is:2PL/SQL 过程已成功完成。
      

  2.   

    su number:=0;
    begin
    for cu in v_cur 
    loop
    if cu.name='a' then
    su:=su+1;
    end if;
    end loop;dbms_output.put_line(su);
    end;
      

  3.   

    带参数的cursorhttp://hi.baidu.com/lgxroom/blog/item/6fb1cd030927f9ef09fa9369.html