Oracle中将游标重置到第一行上

java 代码
  1. create or replace procedure test_cursor(row_count in number) is   
  2.   
  3.        my_id number;   
  4.        row_index number;   
  5.        CURSOR c_cursor IS select id from mytable order by id;   
  6.   
  7. begin   
  8.        row_index := 0;   
  9.        open c_cursor;   
  10.           
  11.        LOOP   
  12.        exit when row_index >= row_count;   
  13.        row_index := row_index + 1;   
  14.           
  15.        FETCH c_cursor INTO my_id;     
  16.           
  17.        dbms_output.put_line(my_id);   
  18.                  
  19.        if(c_cursor%NOTFOUND) then   
  20.            close c_cursor;   
  21.            open c_cursor;   
  22.         end if;   
  23.            
  24.        end loop;   
  25.           
  26.        close c_cursor;   
  27.      
  28. end test_cursor;  
上面的存储过程实现,在走到游标的最后一行后,然后关闭游标,然后重新打开游标然后游标又重新回到第一行上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值