Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: NULL values in arithmetic

Re: NULL values in arithmetic

From: Kevin <Kevin.K.Tong_at_jpl.nasa.gov>
Date: 2000/08/03
Message-ID: <39899C0B.E01858E7@jpl.nasa.gov>#1/1

In Oracle, NULL is not zero. Thus in your select statement, 15+NULL+8+4=?? You have an unknown, aka NULL, so the answer will be NULL, which is exactly what it should be, because no matter what you add to an unknown, you will get unknown.

Use the NVL function to default to a value, if the NULL value occurs such as zero, if that is what you desire.

Matt Pryor wrote:
>
> Hi there,
>
> I'd expect the following query:
>
> select (15+NULL+8+4) from emp;
>
> to ignore the NULL and return the sum of 15,8 and 4. Instead it returns
> NULL.
>
> Is this normal? Why is it? Is there a workaround?
>
> Thanks in advance for any help,
>
> Matt
  Received on Thu Aug 03 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US