I guess whats happening here is that the resulting value is larger than an integer can hold. So its ‘out of range’ of this data type. Integers are 4 Bytes so perhaps you should use a Bigint or a Double which are 8 Bytes.
I suggest you cast it to a double in your query like so:
SELECT SUM(CAST(filesize as double)) FROM documents WHERE companyid = ?
Or if that errors on nulls use
SELECT SUM(CAST(COALESCE(filesize,0) as double)) FROM documents WHERE companyid = ?
or try
SELECT CAST(SUM(filesize) as double) FROM documents WHERE companyid = ?
Just try these and see which one is more efficient (or even valid since I don’t have an ASA install handy to test this out).
oke, thank you very much Robert, both first two, work great.
This was indeed a custom query, but if I had created this SUM inside Servoy, than Servoy itself had also used this CAST??
Harjo:
…if I had created this SUM inside Servoy, than Servoy itself had also used this CAST??
I doubt Servoy does that for you. It’s too specific. In that case you probably had to alter the column to change the datatype from integer to double.
But perhaps Rob Gansevles can answer this one better.
I could not resist, so I created the same SUM in Servoy, and indeed, Servoy does the cast to double, automaticly!!
another reason, to leave the query over to Servoy!