mybitis 批量更新

  1. <!-- 批量插入for Oracle -->  

        <insert id="insertBatch4Oracle" parameterType="List">  

         insert into aa  

           (  

             a,b  

           )  

              <foreach collection="list" item="item" index="index" separator="union all" >  
           
                   select  #{item.a},  
           
                       #{item.b}  
           
                       from dual  
           
                 </foreach>  
           
        </insert>  

          

        <!-- 批量插入for Other -->  

        <insert id="insertBatch4Other" parameterType="List">  

            insert into aa  

              (  

                a,b  

              )  

              VALUES  

              <foreach collection="list" item="obj" index="index" separator="," >  

              (  

                #{obj.a},#{obj.b}  

              )  

              </foreach>  

        </insert>

批量更新

 <update id="batchUpdateStatus" parameterType="list">
        UPDATE PAY_CLEAR_WAITING
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="status = CASE" suffix="ELSE status END,">
                <foreach item="data" collection="list">
                    WHEN INSTRUCT_ID
                    =
                    #{data.instructId} THEN
                    #{data.payClearWaitingStatus}
                </foreach>
            </trim>
            UPDATE_TIME = sysdate
        </trim>
        WHERE
        <foreach item="data" collection="list" separator="or">
            INSTRUCT_ID = #{data.instructId}
        </foreach>
    </update>


你可能感兴趣的:(mybitis 批量更新)