Обсуждение: NULL/0

Поиск
Список
Период
Сортировка

NULL/0

От
David Garamond
Дата:
Does anyone know what the SQL standard say (or doesn't say) about
division by zero for NULL?

--
dave


Re: NULL/0

От
Tom Lane
Дата:
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