• mybatis 批量更新 批量添加


    <!--批量新增-->
    <insert id="addBatch" parameterType="java.util.List">
    insert into stati_alarm_amount_month (id,stati_year_month,stor_conf_id,alarm_amount,out_amount,in_amount) values
    <foreach collection="list" item="item" index="index" separator=",">
    (#{item.id},#{item.statiYearMonth},#{item.storConfId},#{item.alarmAmount},#{item.outAmount},#{item.inAmount})
    </foreach>
    </insert>

    <!--批量更新-->
    <update id="updateBatch" parameterType="java.util.List">
    <foreach collection="list" item="item" index="index" separator=";">
    update stati_alarm_amount_month
    set stor_conf_id=#{item.storConfId},alarm_amount=#{item.alarmAmount},out_amount=#{item.outAmount},in_amount=#{item.inAmount}
    where id=#{item.id}
    </foreach>
    </update>
    <!--批量更新 先删除后插入-->
    <update id="updateBatch" parameterType="java.util.List">
    delete from stati_duration_item_amount_month where stati_year_month=#{statiYearMonth};
    insert into stati_duration_item_amount_month (id,duration_id,stati_year_month,stor_conf_id,item_amount) values
    <foreach collection="list" item="item" index="index" separator=",">
    (#{item.id},#{item.durationId},#{item.statiYearMonth},#{item.storConfId},#{item.itemAmount})
    </foreach>
    ON DUPLICATE KEY UPDATE
    stati_year_month= values(stati_year_month),duration_id=values(duration_id),stor_conf_id=values(stor_conf_id),item_amount=values(item_amount)
    </update>
  • 相关阅读:
    指向指针的指针
    判断是否遵守某个协议
    oc继承,实现,分类
    oc中没有空指针错误
    oc方法
    指针
    Array.diff
    ATM机允许4位或6位密码,而密码只能包含4位或6位数字。 如果函数传递了一个有效的PIN字符串,返回true,否则返回false。
    替换字符串中的字符为“(” 或“)”
    python 异常处理
  • 原文地址:https://www.cnblogs.com/flyShare/p/14808564.html
Copyright © 2020-2023  润新知