读书人

Oracle中的游标如何用?这里如何报错了

发布时间: 2012-02-17 17:50:42 作者: rapoo

Oracle中的游标怎么用?这里怎么报错了????
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;

[解决办法]
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;
[解决办法]
lz
把游表循环改成这样

LOOP

FETCH 。。。
。。。
EXIT WHEN cur_temp%NOTFOUND;
END LOOP

读书人网 >oracle

热点推荐