首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

关于游标通过while遍历的有关问题

2012-07-26 
关于游标通过while遍历的问题declaretempsal drp.t_client.name%typecursor v_mycursor is select *from

关于游标通过while遍历的问题
declare
 tempsal drp.t_client.name%type;
 cursor v_mycursor is select *from drp.t_client where id>tempsal;
 v_currecord v_mycursor%rowtype;
begin
  tempsal:=10000;
  open v_mycursor;
  fetch v_mycursor into v_currecord;
  while 
  v_mycursor%found
  loop
  dbms_output.put_line(v_currecord.name);
  fetch v_mycursor into v_currecord;
  end loop;
  close v_mycursor;
end;

假如我去掉红色的那句,运行的时候就会报:buffer overflow, limit of 10000bytes
不去掉运行就正常了
但是我想问的是我前面不是已经把游标取出来了吗,后面循环的时候为什么还要去取

[解决办法]
while 
v_mycursor%found
----------------
为什么用While 判断游标记录存在 ,

open c_job;
loop

fetch c_job into c_row;
exit when c_job%notfound;
dbms_output.put_line(c_row.empno||'-'||c_row.ename||'-'||c_row.job||'-'||c_row.sal);
end loop;
--关闭游标
close c_job;
[解决办法]
红色的就可以理解为 取值啊 就是把游标里的东西 一条条放到你的变量里

不在循环里放那句的话,那就只是取了第一条的值,后面的都没取到

热点排行