--批量新增
-- 批量新增需要设置 useGeneratedKeys="false" 不然报错ORA-00933: SQL 命令未正确结束
<insert id="XXX" useGeneratedKeys="false">
insert all
<foreach collection="list" item="item">
into t_sypxt_tblylx_sltj(deptid,deptname,total,sort,spgd,type,month)
values (#{item.deptId},#{item.deptName},0,#{item.sort},'1',#{time})
</foreach>
select 1 from dual
</insert>
--批量更新数据
update t_sypxt_tblylx_sltj t
<trim prefix="set" suffixOverrides=",">
<trim prefix="t.total=case" suffix="end,">
<foreach collection="list" item="item">
when deptid=#{item.deptId} then #{item.total}
</foreach>
</trim>
<trim prefix="t.spgd=case" suffix="end,">
<foreach collection="list" item="item">
when deptid=#{item.deptId} then #{item.spgd}
</foreach>
</trim>
</trim>
<where>
t.deptid in(
<foreach collection="list" item="item" separator=",">
#{item.deptId}
</foreach>
)
and t.type='0' and month=#{time}
</where>