oracle之批量处理foreach用法

此文针对增删改查批量操作

批量查询

<select id="QryWXUserList" resultType="LIST" parameterType="java.util.List">
    SELECT * FROM FLB_FLIGHT_LOG_FOC
    WHERE FLIGHT_ID IN
    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
        #{item}
    </foreach>
</select>

批量更新

<update id="updateWXUser" parameterType="java.util.List">
    <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
        UPDATE TABLENAME
        <set>
            NUMBERS =#{item.numbers}
        </set>
        WHERE ID= #{item.id} AND TYPE= #{item.type}
    </foreach>
</update>

批量新增

<insert id="insertWXUser" parameterType="java.util.List">
    INSERT INTO TABLENAME(FIELD1, FIELD2, FIELD3)
    <foreach collection="list" item="item" separator="UNION ALL" >
        SELECT
        #{item.FIELD1},
        #{item.FIELD2},
        #{item.FIELD3}
        FROM DUAL
    </foreach>
<insert>

批量删除

<delete id="deleteWXUser" parameterType="String">
    DELETE FROM SYS_UNIT_CLASS WHERE CLASS_CODE IN
    <foreach collection="list" item="item" index="no"
             open="(" separator="," close=")">
        #{item}
    </foreach>
</delete>

你可能感兴趣的:(oracle之批量处理foreach用法)