业务场景为:根据过滤条件通过SQL语句查出一个数字类型的数据,然后将这个字段依次增加,求总和
BigDecimal lastTotalReq =BigDecimal.ZERO; //定义一个数字变量,默认值为0
FDCSQLBuilder builder1 = new FDCSQLBuilder();
builder1.appendSql("select FORIGINALAPPLYAMT from T_CON_PayRequestBill where cfyxcontractid ='"+projectId+"' and fstate ='4AUDITTED'");
IRowSet rs2 = builder1.executeQuery();
BigDecimal lastTotalReq =BigDecimal.ZERO;
try {
while(rs2.next()){
lastTotalReq = lastTotalReq.add(rs2.getBigDecimal("FORIGINALAPPLYAMT"));
}
}catch (SQLException e) {
e.printStackTrace();
}