public int ifExistRemindWS(String branchId) {
System.out.println("Call Mathod : ifExistRemindWS");
int count = 0;
String hql1 = "select  count(*) " + 
        " from Insurancelist a, Tcpnsthistory b " + 
        " where a.caseId=b.serviceNo  and b.bizFlag = 0 and b.ifLast = 1 and b.ifTemp = 0 " +
        " and a.ifEffect <> 0 and b.tcpnst.branchid='"+branchId+"'";
String hql2 = "select  count(*) " + 
        " from NcInsurancelist a, NcTcpnsthistory b " + 
        " where a.caseId=b.serviceNo  and b.ncIfTemp = 4 " +
        " and a.ifEffect <> 0 and b.tcpnst.branchid='"+branchId+"'";
try {
Session s = HibernateSessionFactory.getSession();
List list = s.createQuery(hql1).list();
if(list.size()!=0)
count = count+Integer.parseInt(list.get(0).toString());
list = s.createQuery(hql2).list();
if(list.size()!=0)
count = count+Integer.parseInt(list.get(0).toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return -1;
}
        return count;
}

解决方案 »

  1.   

    create procedure ifExistRemindWS(v_branchId in varchar2, v_count out number) 
    AS 
       v_tmp number := 0;begin
       select  count(*) into v_count 
       from    Insurancelist a, Tcpnsthistory b 
       where   a.caseId=b.serviceNo  and b.bizFlag = 0 and b.ifLast = 1 and b.ifTemp = 0 
       and     a.ifEffect <> 0 and b.tcpnst.branchid = v_branchId;
       
       select  count(*) into v_tmp 
       from NcInsurancelist a, NcTcpnsthistory b 
       where a.caseId=b.serviceNo  and b.ncIfTemp = 4 
       and a.ifEffect <> 0 and b.tcpnst.branchid = v_branchId;
       
       v_count := v_count + v_tmp;Exception 
       when others then
          v_count := -1;
    end ifExistRemindWS;
      

  2.   

    create procedure ifExistRemindWS(v_branchId in varchar2, v_count out number) 
    AS 
       v_tmp number := 0;begin
       select  count(*) into v_count 
       from    Insurancelist a, Tcpnsthistory b 
       where   a.caseId=b.serviceNo  and b.bizFlag = 0 and b.ifLast = 1 and b.ifTemp = 0 
       and     a.ifEffect <> 0 and b.tcpnst.branchid = v_branchId;
       
       select  count(*) into v_tmp 
       from NcInsurancelist a, NcTcpnsthistory b 
       where a.caseId=b.serviceNo  and b.ncIfTemp = 4 
       and a.ifEffect <> 0 and b.tcpnst.branchid = v_branchId;
       
       v_count := v_count + v_tmp;Exception 
       when others then
          v_count := -1;
    end ifExistRemindWS;
      

  3.   

    create procedure ifExistRemindWS(v_branchId in varchar2, v_count out number) 
    AS 
       v_tmp number := 0;begin
       select  count(*) into v_count 
       from    Insurancelist a, Tcpnsthistory b 
       where   a.caseId=b.serviceNo  and b.bizFlag = 0 and b.ifLast = 1 and b.ifTemp = 0 
       and     a.ifEffect <> 0 and b.tcpnst.branchid = v_branchId;
       
       select  count(*) into v_tmp 
       from NcInsurancelist a, NcTcpnsthistory b 
       where a.caseId=b.serviceNo  and b.ncIfTemp = 4 
       and a.ifEffect <> 0 and b.tcpnst.branchid = v_branchId;
       
       v_count := v_count + v_tmp;Exception 
       when others then
          v_count := -1;
    end ifExistRemindWS;