Chinaunix首页 | 论坛 | 博客
  • 博客访问: 136579
  • 博文数量: 75
  • 博客积分: 3483
  • 博客等级: 中校
  • 技术积分: 820
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-07 08:31
文章分类

全部博文(75)

文章存档

2011年(53)

2010年(22)

我的朋友

分类: Java

2011-03-16 20:44:23

  1. public List<String> getReportRow(String begindate, String enddate, String begindatef, String enddatel, List<ReportRow> rows, List<ReportHead> heads) {
  2.         Connection conn = null;
  3.         CallableStatement cstmt = null;
  4.         ResultSet rs1 = null;
  5.         ResultSet rs2 = null;
  6.         List<String> dates = new ArrayList<String>();
  7.         
  8.         conn = getConnection();
  9.         
  10.         try {
  11.             cstmt = conn.prepareCall("{CALL EMS_AE_REPORT(?,?,?,?,?,?,?,?,?,?,?,?)}");
  12.             
  13.             cstmt.setString(1, begindate);
  14.             cstmt.setString(2, enddate);
  15.             cstmt.setString(3, begindatef);
  16.             cstmt.setString(4, enddatel);
  17.             
  18.             cstmt.registerOutParameter(5, OracleTypes.CURSOR);
  19.             cstmt.registerOutParameter(6, OracleTypes.CURSOR);
  20.             
  21.             cstmt.registerOutParameter(7, OracleTypes.VARCHAR);
  22.             cstmt.registerOutParameter(8, OracleTypes.VARCHAR);
  23.             cstmt.registerOutParameter(9, OracleTypes.VARCHAR);
  24.             cstmt.registerOutParameter(10, OracleTypes.VARCHAR);
  25.             cstmt.registerOutParameter(11, OracleTypes.VARCHAR);
  26.             cstmt.registerOutParameter(12, OracleTypes.VARCHAR);
  27.             
  28.             cstmt.execute();
  29.             
  30.             // Get the two cursor

  31.             rs1 = (ResultSet) cstmt.getObject(5);
  32.             rs2 = (ResultSet) cstmt.getObject(6);
  33.             
  34.             //Get the last 1, 2, 3 month

  35.             dates.add(cstmt.getString(7));
  36.             dates.add(cstmt.getString(8));
  37.             dates.add(cstmt.getString(9));
  38.             dates.add(cstmt.getString(10));
  39.             dates.add(cstmt.getString(11));
  40.             dates.add(cstmt.getString(12));
  41.             
  42.             while(rs1.next()){
  43.                 ReportHead rh = new ReportHead();
  44.                 
  45.                 rh.setAm(rs1.getString(1));
  46.                 rh.setPm(rs1.getString(2));
  47.                 
  48.                 heads.add(rh);
  49.             }
  50.             
  51.             while(rs2.next()){
  52.                 ReportRow rr = new ReportRow();
  53.                 
  54.                 rr.setTname(rs2.getString(1));
  55.                 rr.setEmpid(rs2.getInt(2));
  56.                 rr.setEmpname(rs2.getString(3));
  57.                 rr.setCount(rs2.getInt(4));
  58.                 
  59.                 rows.add(rr);
  60.             }
  61.             
  62.         } catch (SQLException e) {
  63.             e.printStackTrace();
  64.         }finally{
  65.             closeResultSet(rs1);
  66.             closeResultSet(rs2);
  67.             closeStatement(cstmt);
  68.             returnConnection(conn);
  69.         }
  70.         
  71.         return dates;
  72.         
  73.     }

 

  1. CREATE OR REPLACE PROCEDURE EMS_AE_REPORT(I_BEGIN_DATE IN VARCHAR2,
  2.                                           I_END_DATE IN VARCHAR2,
  3.                                           I_BEGIN_DATEF IN VARCHAR2,
  4.                                           I_END_DATEL IN VARCHAR2,
  5.                                           OUT_CURSOR_AMPM OUT SYS_REFCURSOR,
  6.                                           OUT_CURSOR_PMCOUNT OUT SYS_REFCURSOR,
  7.                                           O_BEGIN_DATE1 OUT VARCHAR2,
  8.                                           O_END_DATE1 OUT VARCHAR2,
  9.                                           O_BEGIN_DATE2 OUT VARCHAR2,
  10.                                           O_END_DATE2 OUT VARCHAR2,
  11.                                           O_BEGIN_DATE3 OUT VARCHAR2,
  12.                                           O_END_DATE3 OUT VARCHAR2) AS
阅读(2258) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~