欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mybatis调用oracle存储过程 返回sys_refcursor

程序员文章站 2024-02-10 13:26:16
...
  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层调用


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