我想知道如何检查是否引用游标返回数据。

让我们说我有一个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;

这个代码在更复杂的过程中使用,并在富的查询使用多个表。

我需要在asp.net应用程序从美孚返回的数据,但我也需要做一些事情的时候美孚发现一些数据。

我想重用在几个地方的查询,但我不认为这将是一个观点一个很好的候选人。

什么是最好的办法知道美孚发现些什么呢?

感谢。

有帮助吗?

解决方案

要知道,如果它发现的时候,唯一的办法就是从它取指令:

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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top