多次声明同一光标时出现奇怪的光标行为 [英] Strange Cursor behavior while declaring same cursor multiple times
问题描述
通常,当我用不获取任何记录的查询声明一个游标时:
Usually when I declare a cursor with a query which fetches no records:
EXEC SQL Declare abcd Cursor For Select 'A' abc from dual where 1=2
返回sqlca.sqlcode为0.
the return sqlca.sqlcode is 0.
因此,我在函数中有一个游标,该游标被多次调用.有时,它会提取记录和有时它不取决于处理阶段,但是在某些情况下,声明游标会引发以下错误&在大多数情况下,它可以成功通过:
So I have a cursor in a function which is being called multiple times. Sometimes it fetches records & sometimes it doesn't depending on the process phase, however in certain cases the declare cursor is throwing the below error & in most of the cases it passes successfully:
Code [1403], Error Message: [ORA-01403: no data found]
功能工作流程()
{
declare cursor
open cursor
for(;;)
{
fetch into x
if(sqlca.sqlcode != 0)
break;
update using x
}
close cursor;
commit;
}
请问有人,为什么有时我会发现无数据".我的工作流程有问题.
Can someone please advise, why sometimes I am getting No-Data-Found. Is something wrong in my workflow.
推荐答案
经过大量R& D [基本上是很多printf的]我终于发现了这个错误....
After a lot of R & D [basically lots of printf's] i finally figured out the bug....
declare cursor doesn't change/return sqlca.sqlcode.
IDK它是如何在内部工作的,但是从我的测试程序中,我发现1403来自声明游标&之前的另一个查询.声明游标未返回/更改sqlca.sqlcode 1403持续存在&导致错误.
IDK how it works internally however from my testing program i figured that the 1403 is coming from another query before the declare cursor & declare cursor is not returning/changing sqlca.sqlcode the 1403 persists & causes the error.
如果有人可以解释声明的工作原理,我真的很想&为什么它不返回/操纵sqlca.sqlcode.
Would really like if someone could explain how declare works & why it doesn't return/manipulate sqlca.sqlcode.
这篇关于多次声明同一光标时出现奇怪的光标行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!