I want to use the resultSet.next()
method twice. I mean, I have retrieved 15 rows of employee and their fund (type A
, type B
) details, within these 15 employees, I want to know how many A
funds and B
funds are mapped to each employees.
while (results.next())
{
int rowCount=results.getInt(7);
aCount=BigDecimal.ZERO;
bCount=BigDecimal.ZERO;
for(int i=1;i<=rowCount;i++)
{
if("A".equals(results.getString(4))||"B".equals(results.getString(4)))
{
aCount=aCount.add(BigDecimal.ONE);
} else
{
bCount=bCount.add(BigDecimal.ONE) ;
}
results.next();
}
}
I am using the ROW_NUMBER()
method to get the row count and over partitioned by emp id.
Query is running fine, but I am getting below exception:
Exception in thread "main" com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][3.64.82] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null
Can someone help me, how to handle this ?
Thanks you in advance.