cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Arithmetic overflow occurred

0 Likes
1,216

Bonjour,

   I am trying a simple math calcul that my tabletop cheap calculator can easily handle but Sybase just can't ....


declare @totalsize float

select @totalsize=(894720*4096/1048576)

Arithmetic overflow occurred ... Sybase errorcode 3606

No matter what type I use (numerci, bigint, int, nameit), nothing is working, my database is simple unable to handle this calcul.

Anyone has an idea what's going on!?

View Entire Topic
former_member188958
Active Contributor
0 Likes

The problem is that you may be specifying the dataype of the result set, but you aren't specifying the datatype for the literal numbers.  ASE is defaulting these to INTs, and  (INT) (894720* (INT) 4096 overflows what an INT can hold before it would be converted to a float.

If you added a ".0" to each of these values, ASE would default them to a float or numeric datatype.

You could also use an explicit convert(float, ...) around each literal value.

It is never a bad idea to cast literal values to a specific datatype.