Oracle 10g 如何在布尔表达式中评估 NULL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2692046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How Oracle 10g evaluates NULL in boolean expressions
提问by Phani Kumar PV
if not (i_ReLaunch = 1 and (dt_enddate is not null))
How this epression will be evaluated in Oracle 10g
when the input value of the i_ReLaunch = null
and the value of the dt_enddate
is not null
it is entering the loop.
According to the rules in normal c# and all it should not enter the loop as
it will be as follows with the values.
当 the 的输入值i_ReLaunch = null
和 的值dt_enddate
不为空时,如何在 Oracle 10g 中评估此 epression 将进入循环。根据普通c#中的规则,它不应该进入循环,因为它的值如下。
If( not(false and (true))
= if not( false)
=if( true)
which implies it should enters the loop
If( not(false and (true))
= if not( false)
=if( true)
这意味着它应该进入循环
But it is not happening
但它没有发生
Can someone let me know if i am wrong at any place
有人可以让我知道我是否在任何地方错了
采纳答案by zendar
Boolean operations with NULL value in Oracle return UNKNOWN
- not true or false. So you have something like this:
Oracle 中具有 NULL 值的布尔运算返回UNKNOWN
- 不是 true 或 false。所以你有这样的事情:
If( not(UNKNOWN and (true)) = if not( UNKNOWN) =if( UNKNOWN )
In this case, IF
will treat UNKNOWN as false.
在这种情况下,IF
将 UNKNOWN 视为 false。
If i_relaunch
can be null, then you need to use some of NULL handling functions(NVL, NVL2, NULLIF, COALESCE, LNNVL
) to be sure that you have correct result.
如果i_relaunch
可以为空,那么您需要使用一些空处理函数( NVL, NVL2, NULLIF, COALESCE, LNNVL
) 来确保您得到正确的结果。
See these article for more information:
有关更多信息,请参阅这些文章:
- Nulls: Nothing to Worry About
- Fundamentals of PL/SQL. Scroll down to -
Handling Null Values in Comparisons and Conditional Statements
- 空值:没什么好担心的
- PL/SQL 基础。向下滚动到 -
Handling Null Values in Comparisons and Conditional Statements