如题.
2. 代码.
<update id="batchUpdate" parameterType="java.util.List"> <foreach collection="list" item="list" index="index" open="begin" close=";end;" separator=";"> update Test <set> a =(case when (a is null) then #{list.parm1} else a+#{list.parm1} end) </set> where b= #{list.parm2} </foreach> </update>
该功能实现如果a为空,则也同样赋值,否则累加. parm1,parm2为list的参数,ctrl+f往下翻页 .
推荐把case when改为如下:
a =NVL(a,0)+#{list.parm1}