Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Why getting CX_SY_ARITHMETIC_OVERFLOW when table reduction of type f

igor_klushnev
Explorer

Need help!

I get an exception in subj when exec the command like

sum = REDUCE f( INIT amt = 0

FOR ln IN GROUP grp
NEXT amt = amt + ln-sum )

All the types are f. The maximum value is 1E+8. Numer of values is 38.

Why this happens? And how to avoid this?

1 ACCEPTED SOLUTION

igor_klushnev
Explorer

I've found solution (:

The expression should look like

sum = REDUCE f( INIT amt = value #( )

FOR ln IN GROUP grp
NEXT amt = amt + ln-sum )

3 REPLIES 3

igor_klushnev
Explorer

I've found solution (:

The expression should look like

sum = REDUCE f( INIT amt = value #( )

FOR ln IN GROUP grp
NEXT amt = amt + ln-sum )

or:

...( INIT amt TYPE f 
FOR ...

By the way,

...(INIT amt = 0
FOR ... 

will define the local variable as an integer of 4 bytes because "0" is an integer (same rule as for "DATA(amt) = 0"), so the maximum is around 2E9, I guess the sum of your 38 numbers is above 2E9 hence the overflow.