Re: NULL/0 - Mailing list pgsql-general

From Tom Lane
Subject Re: NULL/0
Date
Msg-id 2796.1095657374@sss.pgh.pa.us
Whole thread Raw
In response to NULL/0  (David Garamond <lists@zara.6.isreserved.com>)
List pgsql-general
David Garamond <lists@zara.6.isreserved.com> writes:
> Does anyone know what the SQL standard say (or doesn't say) about
> division by zero for NULL?

You mean NULL/0 ?

SQL99 6.26 <numeric value expression> saith:

         General Rules

         1) If the value of any <numeric primary> simply contained in a
            <numeric value expression> is the null value, then the result of
            the <numeric value expression> is the null value.

         ...

         4) The dyadic arithmetic operators <plus sign>, <minus sign>,
            <asterisk>, and <solidus> (+, -, *, and /, respectively)
            specify addition, subtraction, multiplication, and division,
            respectively. If the value of a divisor is zero, then an
            exception condition is raised: data exception - division by
            zero.

Given the order of those statements, I'd expect NULL/0 to yield NULL.

            regards, tom lane

pgsql-general by date:

Previous
From: David Garamond
Date:
Subject: NULL/0
Next
From: Neil Conway
Date:
Subject: Re: Prefetch children