mybatis Oracle 批量插入,批量更新

传入的参数只要是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>
原文地址:https://www.cnblogs.com/feixian/p/5960111.html