PL/SQL:从两个函数之间传递的游标中获取
我有一个关于从弱类型游标获取结果的快速问题,想知道以前是否有人遇到过这个问题?
我的设置如下;
内部功能;
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以复制你的问题,对我来说这似乎是一个 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.