'DB2 Comparing data with very large numbers

My DB2 SQL query is failing with msg: sql0802N: Arithmetic overflow or other arithmetic exception occured. SQLSTATE = 22003

Below is the code:

ALTER TABLE MYSCHEMA.MYTABLE
ADD COLUMN DATA_BUCKET VARCHAR(255);

UPDATE MYSCHEMA.MYTABLE
SET DATA_BUCKET = CASE 
WHEN DATAAMT<1000000 then 'Less than 10 lacs' 
    WHEN DATAAMT>=1000000 and DATAAMT<2500000 then '10-25 Lacs'
    WHEN DATAAMT>=2500000 and DATAAMT<5000000 then '25-50 Lacs'
    WHEN DATAAMT>=5000000 and DATAAMT<1*POWER(10, 7) then '50 Lacs-1 Cr'
    WHEN DATAAMT>=1*POWER(10, 7) and DATAAMT<5*POWER(10, 7) then '1-5 Cr'
    WHEN DATAAMT>=5*POWER(10, 7) and DATAAMT<50*POWER(10, 7) then '5-50 Cr'
    WHEN DATAAMT>=50*POWER(10, 7) and DATAAMT<100*POWER(10, 7) then '50-100 Cr'
                        
    WHEN DATAAMT>=100*POWER(10, 7) and DATAAMT<500*POWER(10, 7) then '100-500 Cr'
    WHEN DATAAMT>=500*POWER(10, 7) and DATAAMT<1000*POWER(10, 7) then '500-1000 Cr'
    WHEN DATAAMT>=1000*POWER(10, 7) and DATAAMT<5000*POWER(10, 7) then '1000-5000 Cr'
    WHEN DATAAMT>=5000*POWER(10, 7) and DATAAMT<10000*POWER(10, 7) then '5000-10000 Cr'
    WHEN DATAAMT>=10000*POWER(10, 7) then 'Above 10000 Cr'
    ELSE 'NA' 
    END;
COMMIT;   

I checked my query contains case statement where i am comparing column value with very large numbers. It's failing from number 500 * POWER(10, 7). How can i handle this. I have tried to cast it to double like CAST(500 * POWER(10, 7) as DOUBLE) OR CONVERT but it's not working.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source