declare 
    top varchar2(4000);
    str varchar2(4000);
cursor c1
is
select topic_eng from topic;begin
open c1;
loop
   fetch c1 into top;
   if str is null then
          str:=top;
   else
         str:=str||','||top;
   end if;   exit when c1%notfound;
  
end loop;
 Dbms_Output.put_line(str);
end;
小弟水平有限木看出来这那里不对~ 大哥们帮小弟看看 小弟先谢过了~
我把 Dbms_Output.put_line(str);这句话去了就没有问题 可以执行通过~
小弟没分了~ 只有谢谢了

解决方案 »

  1.   

    因为str太长了,dbms_output.put_line,line是有长度限制的
      

  2.   

    你的游标循环写得又问题
    declare 
        top varchar2(4000); 
        str varchar2(4000); 
       cursor c1 
       is 
       select topic_eng from topic; begin 
      open c1; 
      fetch c1 into top;  
        if c1%found
        loop
           if str is null then 
                  str:=top; 
           else 
                str:=str||','||top; 
           end if; 
        fetch c1 into top;      
      end loop; 
      close c1;
        Dbms_Output.put_line(str); 
    exception
        dbms_output.put_line(sqlerrm,1,200);
    end; 
      

  3.   

    放到oracle自身提供的sql*plus 中执行,
    注意设置以下几个参数即可:
    set linesize   xxxx 可以是 20000
    set pagesize   xxxx 可以是 10000以上
    set severoutput on 
    其他工具暂时有些需要改进的地方。
      

  4.   

    declare 
        top varchar2(4000); 
        str varchar2(4000); 
      cursor c1 
      is 
      select topic_eng from topic; begin 
      open c1; 
      fetch c1 into top;   
        if c1%found 
        loop 
           if str is null then 
                  str:=top; 
           else 
                str:=str||','||top; 
           end if; 
        fetch c1 into top;     
      end loop; 
        dbms_output.put_line(str); 
    exception 
        dbms_output.put_line(sqlerrm); 
    end;