mybatis调用oracle存储过程 返回sys_refcursor


  
  
  1. <code class="language-sql">Map<String, Object> map = new HashMap<String, Object>();  
  2.         map.put("id""0");  
  3.         mapper.selectPosBy(map);  
  4.         return (List) map.get("poss");</code>  

   
   
  1. Map<String, Object> map = new HashMap<String, Object>();
  2. map.put("id", "0");
  3. mapper.selectPosBy(map);
  4. return (List) map.get("poss");

存储过程:

 
 

  
  
  1. create or replace procedure getPosBy(
  2. V_USERID IN NUMBER,
  3. V_CURSOR OUT SYS_REFCURSOR
  4. ) is
  5. begin
  6. OPEN V_CURSOR FOR SELECT * from tb_pos_recode;
  7. end getPosBy;

Mapper.xml


  
  
  1. <update id="selectPosBy" statementType="CALLABLE" parameterType="map">
  2. <![CDATA[
  3. call getPosBy(#{id,mode=IN,jdbcType=DECIMAL},
  4. #{poss,mode=OUT,jdbcType=CURSOR,javaType=java.sql.ResultSet,resultMap=com.lsh.dao.mapper.TbPosRecodeMapper.result})
  5. ]]>
  6. </update>

Dao层或者service层调用


猜你喜欢

转载自blog.csdn.net/huiyeyeyey/article/details/82772042