记忆-oracle游标

概要 

cursor游标类型表示
%foundSQL 语句影响了一行或多行时为 TRUE
%notfoundSQL 语句没有影响任何行时为TRUE
%isopen 游标是否打开
%rowcountSQL 语句影响的行数
open打开游标
close关闭游标
fetch取得游标的一行数据
open 游标名称 for  
游标名称 out sys_refcursor; 

 

举例

1

declare
  cursor rCursor is
    select * from tb2;
  vRow tb2%rowtype;
begin
  if rCursor%isopen then
    null;
  else
    open rCursor;
  end if;
  fetch rCursor
    into vRow;
  while rCursor%found loop
    dbms_output.put_line(rCursor%rowcount||' id:'||vRow.id);
      fetch rCursor
    into vRow;
  end loop;
  close rCursor;
end;

运行结果 

1 id:1
2 id:2
3 id:3
4 id:4
5 id:5
6 id:6
7 id:7
8 id:8
9 id:9
10 id:10
11 id:11
12 id:12

 tb2数据表

2 游标作为输出

create or replace procedure test_procedure3 (rCursor out sys_refcursor)
as
begin
  rCursor open for select * from tb2;
end;

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值