ibatis3.0调用Oracle的存储过程

直接上源码

一,oracle储存过程。 

create or replace procedure proc_get_th(
i_hth in varchar2,
o_ret out sys_refcursor
)
is
begin
for v_rec in (select ggd_id,th from gms_ggd_zt where hth=i_hth)
loop
insert into tmp_gms_plan_th(ggd_id,th)
select ggd_id,th from table(f_get_th(v_rec.ggd_id,v_rec.th));
end loop;

open o_ret for
select gpt.ggd_id,gpt.th
from tmp_gms_plan_th gpt
where (gpt.ggd_id,gpt.th) not in
(select ggd_id,th from gms_plans);

delete from tmp_gms_plan_th;
commit;

end;

二,ibatis的xml配置。

 

<resultMap id="ResultGmsTH" type="com.pisx.app.gms.entity.GmsPlans" >
<result column="GGD_ID" property="ggdId" jdbcType="VARCHAR" />
<result column="th" property="th" jdbcType="VARCHAR" />
</resultMap>

<!--第一种写法 查询语句 --> 缺点:参数值的顺序一定要和数据库对应
<select id="queryPlansByHthProc" parameterType="java.util.Map" statementType="CALLABLE">

<![CDATA[

call proc_get_th(#{hth,mode=IN,jdbcType=VARCHAR},
#{result,mode=OUT,jdbcType=CURSOR,javaType=java.sql.ResultSet,resultMap=ResultGmsTH}
)

]]>

</select>

<!--第二种写法 查询语句 --> 

<select id="queryPlansByHthProc" parameterType="java.util.Map" statementType="CALLABLE">

<![CDATA[

call proc_get_th( hth => #{hth,mode=IN,jdbcType=VARCHAR},
 result => #{result,mode=OUT,jdbcType=CURSOR,javaType=java.sql.ResultSet,resultMap=ResultGmsTH}
)

]]>

</select>

 

三,获取返回值。

 gmsPlansSerivice.queryPlansByHthProc(map);

(List<GmsPlans>) map.get("result");

说明:返回值会自动装在你的参数里面。

 

转载于:https://www.cnblogs.com/luocheng/p/4387696.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值