ORACLE 批量新增 和批量更新

2018-11-13  本文已影响0人  M_ENG

批量新增 parameterType="java.util.List" collection必须为"list"

<insert id="batchInsert" parameterType="java.util.List">

INSERT INTO HIST_LD_CHANGE(LINE_ID,LINE_NAME)

      <foreach collection="list" close=")" open="(" separator="union all" item="item">

          SELECT #{item.lineId},#{item.lineName}      FROM DUAL

      </foreach>
</insert>

批量新增 parameterType="java.util.Map" collection为Map中的listKey "lineList"

<insert id="batchInsert" parameterType="java.util.Map">

INSERT INTO HIST_LD_CHANGE(LINE_ID,LINE_NAME,AREA_ID)

      <foreach collection="lineList" close=")" open="(" separator="union all" item="item">

          SELECT #{item.lineId},#{item.lineName},#{areaId}  FROM DUAL

      </foreach>
</insert>

批量更新 parameterType="java.util.Map"


<foreach collection="zyldList" open="BEGIN" close="END;" item="item" separator=";" index="index">

    UPDATE HIST_LD_CHANGE SET LINE_ID = #{item.lineId},

                              TASK_ID = #{item.taskId},

                              IS_TRANSFER = 1,

                              TRANSFER_USER_ID = #{userId},

                              TRANSFER_TIME = SYSDATE

    WHERE LD_FLIGHT_ID = #{item.ldFlightId} AND IS_PERSONAL_DEL = 0

    <if test="(zyldList.size-1) == index">
        ;
    </if>

</foreach>
上一篇下一篇

猜你喜欢

热点阅读