IBM Support

divide by zero error: divide\mode by zero is invalid.

Troubleshooting


Problem

An error occurs when running a report that contains calculations.

Symptom

EXPENG-E-ZERO DIVR (floating point) divide\mode by zero is invalid.
DMS-E-MATHEXCEPTION an arithmetic exception was detected
Error # -51
EXPENG-E-ZERO DIVR (floating point) divide\mode by zero is invalid.

or

DMS-E-MATHEXCEPTION. an arithmetic exception was detected.
EXPENG-E-ZERO_DIVR. <Floating point> divide/mov by zero is invalid.

or

Abfrage-Serverfehler
Fehlermeldung -237:
DMS-E-GENERAL, Fehler während der Operation 'asynchronous open'
DMS-E-MATHEXCEPTION, Arithmetischer Fehler
EXPENG-E-OVF_FP, Überlauf bei einer <floating point>-Operation

or

Abfrage-Serverfehler
Fehlermeldung -237:
DMS-E-GENERAL, Fehler während der Operation 'asynchronous open'
DMS-E-MATHEXCEPTION, Arithmetischer Fehler
EXPENG-E-ZERO_DIVR, <Floating point> divide/mod durch 0 ist ungültig.

Resolving The Problem

Users wishing to avoid divide by zero errors may try to use the following expression to ensure that the value of B is always non-zero:
if (B <> 0) then (A/B) else (0)

This will work with databases like dBASE where all expressions are executed locally by Impromptu. However, even though Impromptu cannot send the entire conditional expression to a true SQL database server, it will still send those parts that it can -- in this case the expression (A/B) to the server for execution. The result is inserted into the overall expression, so the database will still report a divide by zero error and stop fetching records. In order to avoid divide by zero error, you must voice a conditional expression:
(if (B <> 0) then (A) else( 0)) / (if (B <> 0) then (B) else (1))

Since the division now includes a condition expression which must be executed locally, the division will also be executed locally.

If you are still receiving the error after making the changes to your calculation, it may be because there are NULL values in your data.

An ODBC trace may reveal the following:

EXAMPLE:

SQLError
NULL
NULL
0x0101000E
[5]01S01
89
[57][Microsoft][ODBC Microsoft Access 97 Driver]Error in row
512
57
SQL_SUCCESS
SQLError
NULL
NULL
0x0101000E
[5]22012
21
[67][Microsoft][ODBC Microsoft Access 97 Driver]Division by zero (null)
512
67
SQL_SUCCESS
SQLError
NULL
NULL
0x0101000E
[5]00000
35527920
[0]
512
0
SQL_NO_DATA_FOUND

If this is the case, add a calculation to the columns which may contain NULLs to replace the NULLS with zeros. The calculation should look like this:

if columnname is missing then 0 else columnname

Similarly, you can change the conditions to "is missing" instead of "is not missing"

( if ( (B = 0) or (B is missing) ) then (0) else (A) ) / ( if ( (B = 0) or (B is missing) ) then (1) else (B) )

Scenario 1:

Let's say B = 0

( if ( (B = 0) or (B is missing) ) then (0) else (A) )
First condition is true so A = 0

( if ( (B = 0) or (B is missing) ) then (1) else (B) )
First condition is true so B= 1

Result: A/B = 0/1

Scenario 2:

Let's say B = NULL

( if ( (B = 0) or (B is missing) ) then (0) else (A) )
Second condition is true so A = 0

( if ( (B = 0) or (B is missing) ) then (1) else (B) )
Second condition is true so B= 1

Result: A/B = 0/1

Scenario 3:

Let's say B = 2

( if ( (B = 0) or (B is missing) ) then (0) else (A) )
First and second conditions are false A = A

( if ( (B = 0) or (B is missing) ) then (1) else (B) )
First and second conditions are false so B= B

Result: A/B

[{"Product":{"code":"SSTQPQ","label":"IBM Cognos Series 7 PowerPlay"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Impromptu","Platform":[{"code":"PF025","label":"Platform Independent"},{"code":"PF033","label":"Windows"}],"Version":"Cognos 8 BI Access Manager 7.4;Cognos 8 BI Report Studio 8.1;Impromptu 2.0;Impromptu 3.0;Impromptu 3.01;Impromptu 3.02;Impromptu 3.03;Impromptu 3.04;Impromptu 3.5;Impromptu 3.55;Impromptu 4.0;Impromptu 5.0;Impromptu 6.0;Impromptu 7.0;Impromptu 7.1;Impromptu 7.3;Impromptu 7.4;Impromptu Web Reports 7.3;PowerPlay Client 4.1;PowerPlay Client 5.0;PowerPlay Enterprise Server 7.1;PowerPlay Transformer 4.0;PowerPlay Transformer 7.3","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSEP7J","label":"Cognos Business Intelligence"},"Business Unit":{"code":"BU053","label":"Cloud \u0026 Data Platform"},"Component":"Security","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"","label":""}},{"Product":{"code":"SSEP7J","label":"Cognos Business Intelligence"},"Business Unit":{"code":"BU053","label":"Cloud \u0026 Data Platform"},"Component":"Report Studio","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"","label":""}},{"Product":{"code":"SSTQPQ","label":"IBM Cognos Series 7 PowerPlay"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Impromptu","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSTQPQ","label":"IBM Cognos Series 7 PowerPlay"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Impromptu Web Reports","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSTQPQ","label":"IBM Cognos Series 7 PowerPlay"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"PowerPlay","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSTQPQ","label":"IBM Cognos Series 7 PowerPlay"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"PowerPlay Enterprise Server","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSTQPQ","label":"IBM Cognos Series 7 PowerPlay"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Transformer","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

100914

Document Information

Modified date:
28 November 2022

UID

swg21336545