Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Division by zero
Sun, Jul 12 2020 8:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I'm playing with removing a percentage field and I wanted to see what happened if the divisor was null. I tried

select
_ID,
0 / 0,
COALESCE(_VAT,0) / COALESCE(_Value,0),
_VAT / _Value,
_Value,
_VAT

from analysis

in EDBManager. The three calculations all show NULL in the grid when the divisor is 0.

I don't know why but division by zero returning NULL rather than bombing out seems wrong.

Just wondering what other's opinions are.

Roy Lambert
Sun, Jul 12 2020 2:23 PMPermanent Link

Raul

Team Elevate Team Elevate

On 7/12/2020 8:43 AM, Roy Lambert wrote:
> I don't know why but division by zero returning NULL rather than bombing out seems wrong.
>
> Just wondering what other's opinions are.

NULL would be my expectation - being equivalent of "undefined"  etc

Most of the time we'd have it more indirectly - some computed value(s)
ends up being divided by zero due to a column being 0.

Some DMBS have this as a configurable option even so could be
enhancement request for EDB as well if you want to to throw an exception

Raul
Mon, Jul 13 2020 2:27 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Raul


>Some DMBS have this as a configurable option even so could be
>enhancement request for EDB as well if you want to to throw an exception


I'm not really bothered now I know what its doing, just wondered what others thought. I was just surprised that it was silently handled rather than throwing an error. Googling I found a number of hits on how to use NULLIF to "get round" the error. Since I value my sanity I decided not to try and find out what the standard says Smiley

Roy
Wed, Jul 29 2020 10:04 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Roy,

<<Since I value my sanity I decided not to try and find out what the standard says Smiley>

It says "(...) an exception condition is raised: data exception — division by zero"

--
Fernando Dias
[Team Elevate]
Image