存储过程:
1 create or replace procedure JDGL_PRO_GET_DFLZJSBB3(p_date1 in varchar2, res OUT sys_refcursor) is 2 3 begin 4 5 open res for 6 SELECT COUNT(1) AS COL1, 7 COUNT(null) AS COL2 8 FROM XFAJ09 A 9 WHERE A.DELETEFLAG = '0' 10 AND A.XFAJ0907 BETWEEN TO_DATE('2017-11-01', 'yyyy-mm-dd') 11 AND TO_DATE('2017-11-30', 'yyyy-mm-dd') 12 AND EXISTS ( 13 SELECT DMCOD 14 FROM G099_HIBER GH 15 WHERE (GH.DMPARENTCOD = 'b8652adc-e096-47e1-88fe-d14dbf7b3f9e' 16 OR GH.DMCOD = 'b8652adc-e096-47e1-88fe-d14dbf7b3f9e') 17 AND GH.DMCOD = A.CREATEUSERDEPT 18 ); 19 20 end JDGL_PRO_GET_DFLZJSBB3;
xml文件:
1 <select id="countDFLZAN" parameterType="string" resultType="java.util.LinkedHashMap" statementType="CALLABLE"> 2 {call JDGL_PRO_GET_DFLZJSBB3(#{date1,mode=IN,jdbcType=VARCHAR},#{result,mode=OUT,jdbcType=CURSOR})} 3 </select>
Java代码:
1 @Action 2 public String selectBB3(){ 3 HttpServletRequest request = ActionContext.getActionContext() 4 .getHttpServletRequest(); 5 Map<String, Object> map = new HashMap<String, Object>(); 6 7 Map<String, Object> params = new HashMap<String, Object>(); 8 params.put("date1", "2017-11-01"); 9 params.put("result", null); 10 bdsoftMybatisUtils.selectList("jdgl.dflzjsbb.countDFLZAN", params); 11 ResultSet set = (ResultSet)params.get("result"); 12 try { 13 while (set.next()) { 14 System.out.println(set.getString("COL1")); 15 } 16 } catch (SQLException e) { 17 e.printStackTrace(); 18 } 19 20 return Json.encode(map); 21 }