declare 
        s_Stemp t_xt_qxdzsj.dzmc%type;
        s_Sreturn varchar2(4000) := '';
begin
declare 
        cursor cur_temp is
               select qxbh || '#' || dzmc || ';' as colTemp from t_xt_qxdzsj;
               --retCursor t_xt_qxdzsj % rowtype;
        begin
             Open cur_temp;
             Fetch cur_temp into s_Stemp;
             While (cur_temp % NOTFOUND) loop
                   s_Sreturn := s_Sreturn + to_char(s_Stemp);
                   dbms_output.put_line(s_Stemp || 'While In');
                   Fetch cur_temp into s_Stemp;
             End loop; 
             dbms_output.put_line('我操了,没有的');
        end;
end;

解决方案 »

  1.   

    declare 
            s_Stemp t_xt_qxdzsj.dzmc%type;
            s_Sreturn varchar2(4000) := '';
    cursor cur_temp is
                   select qxbh || '#' || dzmc || ';' as colTemp from t_xt_qxdzsj;
                   --retCursor t_xt_qxdzsj % rowtype;
            begin
                 Open cur_temp;
                 Fetch cur_temp into s_Stemp;
                 While (cur_temp % NOTFOUND) loop
                       s_Sreturn := s_Sreturn + to_char(s_Stemp);
                       dbms_output.put_line(s_Stemp || 'While In');
                       Fetch cur_temp into s_Stemp;
                 End loop; 
                 dbms_output.put_line('我操了,没有的');
            end;
      

  2.   

    Sorry,我说错了,不是报错,而是while里面那一块没有执行,t_xt_qxdzsj改表确定有值
      

  3.   

    单步调试一下select qxbh || '#' || dzmc || ';' as colTemp from t_xt_qxdzsj;
    看看这句话是否有结果
      

  4.   

    select qxbh || '#' || dzmc || ';' as colTemp from t_xt_qxdzsj; 有的t_xt_qxdzsj该表确定有值
      

  5.   

    While (cur_temp % NOTFOUND) loop
    当游标没有的时候才进入循环阿declare 
            s_Stemp varchar2(20);
            s_Sreturn varchar2(200) := '';
    begin
    declare 
            cursor cur_temp is
                   select area_id || '#' || area_id || ';' as colTemp from b_areas;
                   --retCursor t_xt_qxdzsj % rowtype;

            begin
    Open cur_temp;
                 
     LOOP
                  
               FETCH cur_temp INTO s_Stemp;      
            dbms_output.put_line(s_Stemp );
                  EXIT WHEN cur_temp%NOTFOUND;                 
               END LOOP;/*
                 Fetch cur_temp into s_Stemp;
                 While (cur_temp % NOTFOUND) loop
                       s_Sreturn := s_Sreturn || to_char(s_Stemp);
                       --dbms_output.put_line(s_Stemp || 'While In');
       dbms_output.put_line(s_Stemp );
                       Fetch cur_temp into s_Stemp;
                 End loop; */
                 dbms_output.put_line('没有的');
            end;
    end;
      

  6.   

    lz
    把游表循环改成这样 LOOP
            
               FETCH 
          
                  EXIT WHEN cur_temp%NOTFOUND;                 
               END LOOP
      

  7.   

    或者
    While (cur_temp % FOUND) loop

      END LOOP