mybatis调用oracle存储过程 返回sys_refcursor


 
 
   
   
   
   
[java] view plain copy
print ?
  1. class="language-sql">Map map = new HashMap();  
  2.         map.put("id""0");  
  3.         mapper.selectPosBy(map);  
  4.         return (List) map.get("poss");  

  
  
    
    
    
    
  1. Map map = new HashMap();
  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. call getPosBy(#{id,mode=IN,jdbcType=DECIMAL},
  3. #{poss,mode=OUT,jdbcType=CURSOR,javaType=java.sql.ResultSet,resultMap=com.lsh.dao.mapper.TbPosRecodeMapper.result})
  4. ]]>
  5. update>

Dao层或者service层调用


来源出自 https://blog.csdn.net/lsh009/article/details/8717131

你可能感兴趣的:(sql)