create or replace procedure get_count
  2  as
  3  a varchar2(20);
  4  cursor c_wap_user_enter_log is
  5  select mobile into a from wap_user_enter_log;
  6  begin
  7  for v_wap_user_enter_logRecord in c_wap_user_enter_log loop
  8  dbms_output.put_line('mobile='||a);
  9  end loop;
 10  end;
 11  /小弟写了这样一个存储过程,但是执行过后,无法显示出想要查询的mobile,全部为mobile=,而且报错
ERROR at line 1:
ORA-20000: ORU-10027: buffer overflow, limit of 2000 bytes
ORA-06512: at "SYS.DBMS_OUTPUT", line 35
ORA-06512: at "SYS.DBMS_OUTPUT", line 198
ORA-06512: at "SYS.DBMS_OUTPUT", line 139
ORA-06512: at "SCWAP.GET_COUNT", line 8
ORA-06512: at line 1

解决方案 »

  1.   

    你没有做fectch into 
    声明游标的时候不能into赋给变量
    要通过fetch 把值赋给变量
      

  2.   

    把 select mobile into a from wap_user_enter_log;
    改为 select mobile from wap_user_enter_log;把 dbms_output.put_line('mobile='||a);
    改为dbms_output.put_line('mobile='||mobile);试一试
      

  3.   

    for v_wap_user_enter_logRecord in c_wap_user_enter_log loop
    这句什么意思?
      

  4.   

    up.
    /*a没有给它值,能显示出什么?只有mobile.*/
      

  5.   

    create or replace procedure get_count
       as
        a varchar2(20);
        cursor c_wap_user_enter_log is
        select mobile  from wap_user_enter_log;
        begin
         open c_wap_user_enter_log ;
        loop
        fetch c_wap_user_enter_log into a;
        if c_wap_user_enter_log%notfound then
        exit;
        end if;
        dbms_output.put_line('mobile='||a);
        end loop;
        close c_wap_user_enter_log;
       end;
      

  6.   

    create or replace procedure get_count
    as
        a varchar2(20);
        cursor c_wap_user_enter_log is
            select mobile from wap_user_enter_log;
    begin
        for v_wap_user_enter_logRecord in c_wap_user_enter_log loop
            a:=v_wap_user_enter_logRecord.mobile;
            dbms_output.put_line('mobile='||a);
        end loop;
    end;
    /
    这样应该没有什么问题吧?