oracle ORA-24347: 聚合函数中的 NULL 列警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11771462/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:00:48  来源:igfitidea点击:

ORA-24347: Warning of a NULL column in an aggregate function

c++sqloracleoracle11gaggregate-functions

提问by Vijay Vasanth

I'm getting this warning:

我收到此警告:

ORA-24347: Warning of a NULL column in an aggregate function

when using Oracle's MAX()function in production. I'm using the OCI library to connect to Oracle, version 11.2.0.2.

MAX()在生产中使用 Oracle 的功能时。我正在使用 OCI 库连接到版本 11.2.0.2 的 Oracle。

But, on the testing server, this error is not coming. I've hard-coded the query in such way that a NULLvalue can be passed to an aggregate function. I still couldn't reproduce this issue.

但是,在测试服务器上,不会出现此错误。我已经对查询进行了硬编码,以便将NULL值传递给聚合函数。我仍然无法重现这个问题。

Is this warning related to any Oracle bug? Can anyone provide some example query which will throw this warning?

此警告是否与任何 Oracle 错误有关?任何人都可以提供一些会引发此警告的示例查询吗?

Edit:

编辑:

Table: EX_TABLE
Columns:
ID NOT?NULL NUMBER
SOME_NUMBER NUMBER
MAX_VAL NUMBER

Query:

询问:

select MAX(DECODE(some_number,1,max_val,NULL)) val1
     , MAX(DECODE(some_number,2,max_val,NULL)) val2
     , MAX(DECODE(some_number,3,max_val,NULL)) val3 
  from EX_TABLE

回答by Samson

You should decode the values with 0 not with NULL;

您应该使用 0 而不是 NULL 来解码值;

select MAX(DECODE(some_number,1,max_val,0)) val1,
       MAX(DECODE(some_numer,2,max_val,0)) val2,
       MAX(DECODE(some_numer,3,max_val,0)) val3 
  from EX_TABLE