PL/SQL:从两个函数之间传递的游标中获取

发布于 2024-07-09 09:19:54 字数 1385 浏览 9 评论 0原文

我有一个关于从弱类型游标获取结果的快速问题,想知道以前是否有人遇到过这个问题?

我的设置如下;

内部功能;

create or replace FUNCTION A_CURSOR_TEST_INNER
(
  varCursor OUT SYS_REFCURSOR
)
RETURN NUMBER
AS
  varStatus NUMBER;
BEGIN
  OPEN varCursor  FOR
  SELECT docid
  FROM DOCUMENT_TABLE;

  RETURN 0;
END;

调用功能;

create or replace FUNCTION A_CURSOR_TEST_OUTER
(
  varCursor  OUT SYS_REFCURSOR
)
RETURN NUMBER
AS
  varStatus NUMBER;
BEGIN
  varStatus := A_CURSOR_TEST_INNER(varCursor  => varCursor);
  RETURN 0;
END;

测试工具代码;

DECLARE
  varCursor  SYS_REFCURSOR;
  v_Return NUMBER;
BEGIN
  v_Return := A_CURSOR_TEST_OUTER(varCursor  => varCursor);
    DECLARE
        docid_ NUMBER;
    BEGIN
        IF(varCursor %ISOPEN) THEN
            LOOP
                FETCH varCursor  INTO docid_ ;
                EXIT WHEN varCursor %NOTFOUND;
                DBMS_OUTPUT.PUT_LINE(' docid_:' || docid_ );
            END LOOP;
            CLOSE varCursor ;
        END IF;
    END;
END;

如果我运行我的测试工具代码,我得到的错误是;

ORA-06504: PL/SQL: 返回类型 结果集变量或查询不 匹配

我不太确定是什么导致了这种情况的发生。 该错误发生在我的测试代码中,但我之前已经使用过数百次完全相同的方法,但没有遇到此问题。 现在唯一的区别是,光标通过两个函数而不是一个函数向上传递。

有谁知道这里可能出现什么问题吗? 我用谷歌搜索了一下,我能找到的只是强类型光标的建议,不幸的是,这对我来说不是一个选择。

感谢任何人都可以提供的帮助,干杯。

I have a quick question about fetching results from a weakly typed cursor and was wondering if anyone had come across this problem before?

My set up is as follows;

Inner function;

create or replace FUNCTION A_CURSOR_TEST_INNER
(
  varCursor OUT SYS_REFCURSOR
)
RETURN NUMBER
AS
  varStatus NUMBER;
BEGIN
  OPEN varCursor  FOR
  SELECT docid
  FROM DOCUMENT_TABLE;

  RETURN 0;
END;

Calling function;

create or replace FUNCTION A_CURSOR_TEST_OUTER
(
  varCursor  OUT SYS_REFCURSOR
)
RETURN NUMBER
AS
  varStatus NUMBER;
BEGIN
  varStatus := A_CURSOR_TEST_INNER(varCursor  => varCursor);
  RETURN 0;
END;

Test harness code;

DECLARE
  varCursor  SYS_REFCURSOR;
  v_Return NUMBER;
BEGIN
  v_Return := A_CURSOR_TEST_OUTER(varCursor  => varCursor);
    DECLARE
        docid_ NUMBER;
    BEGIN
        IF(varCursor %ISOPEN) THEN
            LOOP
                FETCH varCursor  INTO docid_ ;
                EXIT WHEN varCursor %NOTFOUND;
                DBMS_OUTPUT.PUT_LINE(' docid_:' || docid_ );
            END LOOP;
            CLOSE varCursor ;
        END IF;
    END;
END;

The error I get if I run my test harness code is;

ORA-06504: PL/SQL: Return types of
Result Set variables or query do not
match

I'm not really sure what is causing this to occur. The error is happening in my test code, but I've used this exact same method hundreds of times before and not encountered this problem. The only difference now being, that the cursor is being passed back up through two functions instead of just one.

Does anyone have any idea what the problem might be here? I've Googled around for it and all I can find are suggestions to strongly type the cursors, which is not an option for me unfortunately.

Thanks for any help anyone can give, cheers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

老街孤人 2024-07-16 09:19:54

我可以复制你的问题,对我来说这似乎是一个 Oracle 错误。 通过谷歌搜索错误,我发现这个讨论OraFAQ 上有同样的问题

I can replicate your problem, and it seems like an Oracle bug to me. From Googling the error I found this discussion of the same problem on OraFAQ.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文