0

在循环中,我正在调用参数化游标。在任何特定步骤中,如果游标返回行,则此循环结束,我必须将游标作为参考游标返回。如何在不执行两次相同查询的情况下检查行数?

procedure pr_test
(
    v_data varray;
    ,ret_data sys_refcursor
)
as
    cursor c_q(x)
    select * from table
    where col1 = x;
    ...
begin
    ...
    for  in 1..v_data.count loop
        open ret_data for c_q(v_data(i));
                 ----- here some logic is required --------
        /*if rowcount of re_data > 0 then
            return ret_data;
        else
            close ret_data;
        end if;*/
    end loop;
end;
4

1 回答 1

0

没有办法实现这一点。光标充当生产者-消费者设计模式。这意味着在完全获取游标之前,没有人知道将重新调整多少行。

在 OCI 中,您可以使用可回绕的游标——这些游标可以回绕到开头,但据我所知,这些游标无法从 PL/SQL 访问。

于 2014-02-10T11:39:26.237 回答