Mar*_*tin 2 oracle plsql cursor ref-cursor
我想知道如何检查引用游标是否返回数据.
假设我在PL/SQL包中有以下代码:
type refcursor is ref cursor;
procedure Foo(cursorresult out refcursor) is
begin
open cursorresult for
select *
from table t
inner join t2 on t.id = t2.id
where t.column1 is null;
end;
procedure DoSomeghingIfFooHasResults is
curFoo refcursor;
begin
Foo(curSansOwner);
if curFoo%found then
-- Do something
end if;
end function;
Run Code Online (Sandbox Code Playgroud)
此代码用于更复杂的过程,Foo中的查询使用多个表.
我需要在asp.net应用程序中从Foo返回的数据,但是当Foo找到一些数据时我也需要做一些事情.
我想在几个地方重用查询,但我认为这不适合视图.
什么是最好的方式来知道Foo是否找到了什么?
谢谢.
知道它是否找到了什么的唯一方法是从它获取FETCH:
procedure DoSomeghingIfFooHasResults is
curFoo refcursor;
recFoo mytable%ROWTYPE;
begin
Foo(curFoo);
fetch curFoo into recFoo;
if curFoo%found then
-- Do something
end if;
end function;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14537 次 |
| 最近记录: |