1

I am new to apache metamodel. And I need to run following query using apache metamodel.

"select sum(cast(columnName as decimal)) from table;"

I know that a query containing simple sum function looks like the one given below:

Query query = dataContext.query().from(table).select(FunctionType.SUM, table.getColumnByName(columnName)).toQuery();

But I need to use a cast function because depending on the number of records in particular table the result of the sum can be too big than a value which an integer can hold. Thus causing an exception "Arithmetic overflow error converting expression to data type int." to be thrown when there are millions of records in a table. Can anyone tell me how to apply a cast function when composing a query to be executed with apache metamodel.

TGiri
  • 131
  • 6

0 Answers0