目录
存储过程
调用测试
游标
Mapper.xml
Mapper
调用测试
结果
存储过程
CREATE OR REPLACE PROCEDURE proc_test2(p_id             IN NUMBER,v_cur            OUT SYS_REFCURSOR,p_result_code    OUT NUMBER,p_result_message OUT VARCHAR2) AS
BEGINp_result_message := '成功';p_result_code    := '1';open v_cur forselect 1 id, 'test01' namefrom dualunion allselect 2, 'test02' from dual;END;调用测试

游标
 
Mapper.xml
    <resultMap id="BaseResultMap2" type="com.lxw.lxwDemo.pojo.Test"><id column="ID" property="id" jdbcType="DECIMAL" /><result column="NAME" property="name" jdbcType="VARCHAR" /></resultMap><select id="proc_test2" statementType="CALLABLE">{call proc_test2(#{p_id,jdbcType=DECIMAL,mode=IN},#{v_cur,jdbcType=CURSOR,mode=OUT,resultMap=BaseResultMap2,javaType=java.sql.ResultSet},#{p_result_code,jdbcType=DECIMAL,mode=OUT},#{p_result_message,jdbcType=VARCHAR,mode=OUT})}</select>Mapper
    void proc_test2(Map map);调用测试
    @Autowiredprivate TestMapper testMapper;@Testpublic void proc_test2() {Map map=new HashMap();testMapper.proc_test2(map);List<com.lxw.lxwDemo.pojo.Test> tests= (List) map.get("v_cur");System.out.println(map);System.out.println(JSON.toJSONString(map));System.out.println(JSON.toJSONString(tests));}结果
