需求描述:
对于银承质押签银承的业务,将保证金比例改为圈存比例,并将其置为必输项,保证金金额改为圈存金额。
第一次写的代码:
if(sBusinessType.equals("2010")){ sSql = "select GuarantyType from GUARANTY_INFO "+ "where GuarantyID in (select GuarantyID from GUARANTY_RELATIVE where ObjectType = 'BusinessContract'"+ "and ObjectNo = '"+sObjectNo+"') "; rs = Sqlca.getASResultSet(sSql); if(rs.next()) { sGuarantyType = rs.getString("GuarantyType"); if(sGuarantyType == null) sGuarantyType = ""; } rs.getStatement().close(); }
SQL逻辑:根据业务合同号到Guaranty_relative表查询该合同下的担保品,在到Guaranty_Info查询该担保品的类型,结果集中存放的是担保品类型,这样写是有问题的,没有考虑一笔合同下可能存在多个担保品,这样最好的结果集是不至1行的,如果有3个担保品,其中银承质押的在结果集的第二行,那么if(rs.next())后面的代码就不能实现需求了。
更改后的代码:
1 2 if(sBusinessType.equals("2010")){//银承质押签发银承 3 sSql = "select count(*) from GUARANTY_INFO "+ 4 "where GuarantyID in (select GuarantyID from GUARANTY_RELATIVE where ObjectType = 'BusinessContract' and ObjectNo = '"+sObjectNo+"') "+ 5 "and GuarantyType='020210'"; 6 rs = Sqlca.getASResultSet(sSql); 7 if(rs.next()){ 8 int i = rs.getInt(1); 9 if(i>0){ 10 doTemp.setHeader("BailRatio","圈存比例"); 11 doTemp.setHeader("BailSum","圈存金额"); 12 } 13 rs.getStatement().close(); 14 } 15 }
SQL逻辑,查询该笔合同下类型为银承质押的抵质押物记录条数,大于零则设置业务 逻辑。