批量更新update、批量插入insert


1、批量更新update

  int updateBatch(Map<String, Object> m);

  <update id="updateBatch">
    update fc_naturaldanger_item_t
    set checkret_bigd =
    <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
      when #{item.id} then #{item.checkretBigd}
    </foreach>
      where id in
    <foreach collection="list" item="item" index="index" separator="," open="(" close=")">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>

2、批量插入insert

  int insertBath(Map<String, Object> m);

  <insert id="insertBath">
    insert into fc_naturaldanger_item_t (dangerstudyid,dangerid, checkret)
    values 
    <foreach collection="list" item="item" separator=",">
      (#{dangerstudyid}, #{item.dangerid}, #{item.checkret})
    </foreach>
  </insert>        //id为自增长状态

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM