Re: missing divide by zero error

Adam Baratz <[email protected]> Tue, 11 Oct 2016 14:09:27 -0400
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CADxrgCNJ1+5d+OVP7a64Q2xDjOtuQC1uft3UJq6wOccXTR-mtQ@mail.gmail.com>
I dug into this issue some more. I had misread the log. There was an info
response with a "Division by zero occurred." message following the result.
My handler ignored it because it came with a severity of 0. The message
number, 3607, came through correctly.

For comparison, I tried this query:

> BEGIN TRY
>     SELECT 1/0;
> END TRY
> BEGIN CATCH
>     SELECT
>         ERROR_NUMBER() AS ErrorNumber,
>         ERROR_SEVERITY() AS ErrorSeverity,
>         ERROR_STATE() AS ErrorState,
>         ERROR_PROCEDURE() AS ErrorProcedure,
>         ERROR_LINE() AS ErrorLine,
>         ERROR_MESSAGE() AS ErrorMessage;
> END CATCH;


When run in SSMS, it produces two rowsets: one with no columns, one with
error info:

> ErrorNumber ErrorSeverity ErrorState ErrorProcedure ErrorLine ErrorMessage
> 8134 16 1 NULL 2 Divide by zero error encountered.


Interestingly, the message string is different.

When run with my code, it produces two rowsets: one with no columns, one
with a single NULL result.

It doesn't seem like FreeTDS is related to this issue. I'm wondering, more
generally now, if anyone's experienced issues like this, where queries run
over db-library return very different results, and how they've tried to
trap these differences.

Thanks,
Adam