首页 > 数据库技术 > 详细

mybatis Oracle 批量插入,批量更新

时间:2018-02-03 16:49:06      阅读:219      评论:0      收藏:0      [点我收藏+]
传入的参数只要是list类型的参数就行了。。。。。。。。。。。。。。
1、批量插入

<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO T_CITY_INDEX(
id,city_code
)
select SEQ_CITY_INDEX.NEXTVAL,cd.* from(
<foreach collection="list" item="item" index="index" close=")" open="(" separator="union">
select
#{item.cityCode,jdbcType=VARCHAR},
#{item.cityName,jdbcType=VARCHAR}
from dual
</foreach>
) cd
</insert>

2、批量跟新

<update id="updateBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
update T_CITY_INDEX t
set
t.city_name= #{item.cityName,jdbcType=VARCHAR} ,
t.district_name= #{item.districtName,jdbcType=VARCHAR} ,
where t.id = #{item.id,jdbcType=NUMERIC}
</foreach>
</update>

mybatis Oracle 批量插入,批量更新

原文:https://www.cnblogs.com/xiaoliu66007/p/8409864.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!