问题描述
提出了一个非常有趣的观点:在Oracle文档中似乎存在一个矛盾,即在提取后是否可能%NOTFOUND
为null。是吗?
This question raised a very interesting point; there seems to be a contradiction in the Oracle documentation on whether it's possible for %NOTFOUND
to be null after a fetch. Is it?
引用
文档似乎直接矛盾,因为它也说明了以下情况,这意味着在获取%NOTFOUND
后不能 null。
The documentation seems to directly contradict itself as it also says the following, which implies that after a fetch %NOTFOUND
cannot be null.
10g文档有一个类似的警告,这不一定是一个直接的矛盾,因为它警告一个抓取可能无法成功执行,为了展现这个行为。
The 10g documentation has a similar warning, which isn't, necessarily, a direct contradiction as it warns that a fetch might not execute successfully in order for this behaviour to be exhibited.
EXIT WHEN c1%NOTFOUND或c1%NOTFOUND IS NULL;
EXIT WHEN c1%NOTFOUND OR c1%NOTFOUND IS NULL;
在什么情况下可能会提取失败或可能%NOTFOUND
fetch已执行?
In what situations might a fetch either "fail" or might %NOTFOUND
return null after a fetch has been executed?
推荐答案
我可以找到抓取失败的情况:
I can find a situation where a fetch can fail:
declare
i integer;
cursor c is
select 1 / 0 from dual;
begin
open c;
begin
fetch c
into i;
exception
when others then
dbms_output.put_line('ex');
end;
if c%notfound is null then
dbms_output.put_line('null');
elsif c%notfound then
dbms_output.put_line('true');
else
dbms_output.put_line('false');
end if;
close c;
end;
但这只会使你的问题更强,因为它将评估为null,无论在10g还是在11g。 ..
But this only makes your question stronger since it will evaluate to null, neither in 10g nor in 11g ...
这篇关于可以%NOTFOUND在获取后返回null?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!