Why am I Getting a "[Sql0802] Data Conversion of Data Mapping Error" Exception

Why am I getting a [SQL0802] Data conversion of data mapping error exception?

The only solution I could find was to write a script that checks for blank values in the column and then updates them to zero when they are found.

SQL0802 - Data Conversion or Data Mapping Error

If the problem is divide-by-zero, you simply need to prevent the division from happening when the denominator is zero. The easiest way would be to sum the numerator and denominator separately, then divide after that happens:

       sum (
DB1.Tb1.CUR_CASH_SALES+DB1.Tb1.CUR_CHARGE_SALES-
DB1.Tb1.CUR_CASH_COST+DB1.Tb1.CUR_CHARGE_COST
) /
sum (
DB1.Tb1.CUR_CASH_SALES+DB1.Tb1.CUR_CHARGE_SALES
) as "Gross Margin"

Then you would only get a divide-by-zero if the denominator is zero for the entire category you are grouping on.

If it is still a problem, you will need to do something else in addition. Depending on what you want, you could:

  • Use your where clause to exclude groups with a zero denominator from your output.
  • Put a case statement around the entire calculation that checks if the denominator is zero before calculating. If it is zero, replace the calculation with whatever output makes sense (zero, null, etc.).

Why am I getting Data conversion or data mapping error. SQLCODE=-802 on a simple DB2 select statement?

There was invalid decimal data in the table. There were blanks instead of zeros. I moved zeros into those blanks and that fixed the problem



Related Topics



Leave a reply



Submit