Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

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

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

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
like image 494
Vijay Vasanth Avatar asked Aug 02 '12 05:08

Vijay Vasanth


1 Answers

You should decode the values with 0 not with 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
like image 140
Samson Avatar answered Oct 07 '22 21:10

Samson