oracle中如何让null等于null
我有一个变量被传递到我的存储过程,它是一个过滤器(基本上)。但是,该字段有时可能为空,如果是,我希望能够检查该字段为空的行。
例如,
表 A:
VALUE_COLUMN | FILTER_COLUMN
----------------------------
A | (NULL)
B | (NULL)
C | (NULL)
D | (NULL)
A | 1
E | (NULL)
F | (NULL)
B | 1
查询(包含输入、val、过滤器):
SELECT COUNT(1)
FROM TableA
WHERE
wrap_up_cd = val
AND brn_brand_id = filter
预期 I/O:
val = A, filter = (null) = 1
val = A, filter = 1 = 1
val = C, filter = 1 = 0
如何使 Oracle 表现出这种方式?
I have a variable being passed to my stored proc and it's a filter (basically). However, that field can sometimes be null, and if it is, I want to be able to check against the rows that have that field as null.
For example,
Table A:
VALUE_COLUMN | FILTER_COLUMN
----------------------------
A | (NULL)
B | (NULL)
C | (NULL)
D | (NULL)
A | 1
E | (NULL)
F | (NULL)
B | 1
The query (With inputs, val, filter):
SELECT COUNT(1)
FROM TableA
WHERE
wrap_up_cd = val
AND brn_brand_id = filter
Expected I/O:
val = A, filter = (null) = 1
val = A, filter = 1 = 1
val = C, filter = 1 = 0
How can I make Oracle behave this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
怎么样:
我不是 Oracle 专家,但我期望能够工作 - 如果过滤器和值都为 NULL,基本上会使查询匹配。
How about:
I'm not an Oracle expert, but I'd expect that to work - basically make the query match if both the filter and the value are NULL.
Oracle 没有
ISNULL
函数。所以你需要类似的东西Oracle doesn't have an
ISNULL
function. So you'd need something like有时这也很方便:
This can also be handy at times: