oracle下mybatis中的批量更新

<update id="updateBatch"  parameterType="java.util.List">

   <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
      //里面为内容
    </foreach>
</update>

oracle下的批量更新,中间部分如上所示,不能如传统的一般更新,也可以如下操作:

 <update id="updateClaimDetails" parameterType="java.util.List">
   begin 
   <foreach separator=";" index="index" item="item" collection="list" close="" open="">
     update T_CLAIM_DETAILS
     <set>


      <if test="item.accountingSubjectNum != null and item.accountingSubjectNum !='' ">
         ACCOUNTING_SUBJECT_NUM = #{item.accountingSubjectNum,jdbcType=VARCHAR},
      </if>
      <if test="item.taxSubjectNum != null and item.taxSubjectNum !='' ">
         TAX_SUBJECT_NUM = #{item.taxSubjectNum,jdbcType=VARCHAR},
      </if>


      </set>
       where PK_ID = #{item.pkId,jdbcType=VARCHAR}
    </foreach>   
    ;end;
  </update>


  


版权声明:本文为qq_22114447原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。