mybatis调用Oracle存储过程 带游标

 目录

存储过程

调用测试

游标

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
BEGIN

  p_result_message := '成功';
  p_result_code    := '1';

  open v_cur for
    select 1 id, 'test01' name
      from dual
    union all
    select 2, 'test02' from dual;

END;

调用测试

mybatis调用Oracle存储过程 带游标_第1张图片

游标

 ​​​​​​​mybatis调用Oracle存储过程 带游标_第2张图片

Mapper.xml

    
        
        
    

    

Mapper 

    void proc_test2(Map map);

调用测试

    @Autowired
    private TestMapper testMapper;

    @Test
    public void proc_test2() {

        Map map=new HashMap();
        testMapper.proc_test2(map);
        List tests= (List) map.get("v_cur");

        System.out.println(map);
        System.out.println(JSON.toJSONString(map));

        System.out.println(JSON.toJSONString(tests));
    }

结果

​​​​​​​

你可能感兴趣的:(java,Oracle,mybatis,oracle,数据库)