NULL/0

Started by David Garamondover 21 years ago2 messagesgeneral
Jump to latest
#1David Garamond
lists@zara.6.isreserved.com

Does anyone know what the SQL standard say (or doesn't say) about
division by zero for NULL?

--
dave

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Garamond (#1)
Re: NULL/0

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