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;
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;
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;
看看这句话是否有结果
当游标没有的时候才进入循环阿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;
把游表循环改成这样 LOOP
FETCH
EXIT WHEN cur_temp%NOTFOUND;
END LOOP
While (cur_temp % FOUND) loop
END LOOP