亲宝软件园·资讯

展开

mybatis 调用 Oracle 存储过程

Desperado! 人气:0

存储过程

  PROCEDURE P_TEST_MYBATIS(iv_ins1 IN VARCHAR2, --id
                           iv_ins2 IN VARCHAR2, --no
                           ov_res  OUT number --提示信息
                           ) IS
  BEGIN
    ov_res := 0;
    select count(1)
      into ov_res
      from jc_zhiydoc t
     where t.zhiy_id = iv_ins1
       and t.zhiy_no = iv_ins2;
  
  EXCEPTION
    WHEN OTHERS THEN
      RAISE;
  END;

mapper.xml

这里我是在pkg_ck_task包下面的存储过程

    <select id="exec" statementType="CALLABLE">
        call   pkg_ck_task.P_TEST_MYBATIS(
            #{iv_ins1},
            #{iv_ins2},
            #{ov_res,jdbcType=INTEGER,mode=OUT}
        )

    </select>

dao层

  void exec(Map<String,Object> params);

调用

    public int exec(){
        Map<String,Object> map = new HashMap<>();
        map.put("iv_ins1","ZIY00007709");
        map.put("iv_ins2","0103");
        mapper.exec(map);
        int res =  (int)map.get("ov_res");
        return res;
    }

结果:

加载全部内容

相关教程
猜你喜欢
用户评论