1. 程式人生 > >mybatis+oracle實現批量更新

mybatis+oracle實現批量更新


    <update id="batchUpdateByParams">
        <foreach collection="paramList" item="item" index="index" separator=";"  open="begin" close=";end;">
          UPDATE T_CHANNEL_TRADE_ORDER SET ID = #{item.id,jdbcType=DECIMAL}
            <if test="order.partnerId != null and order.partnerId != ''">
                ,PARTNER_ID = #{order.partnerId}
            </if>
            <if test="order.declareBatchNo != null and order.declareBatchNo != ''">
                ,DECLARE_BATCH_NO = #{order.declareBatchNo}
            </if>
            <if test="order.orderNo != null and order.orderNo != ''">
                ,ORDER_NO = #{order.orderNo}
            </if>
            <if test="order.subMemberCode != null and order.subMemberCode != ''">
                ,SUB_MEMBERCODE = #{order.subMemberCode}
            </if>
            <if test="order.supplyName != null and order.supplyName != ''">
                ,SUPPLY_NAME = #{order.supplyName}
            </if>
            <if test="order.orderDate != null and order.orderDate != ''">
                ,ORDER_DATE = #{order.orderDate}
            </if>
            <if test="order.goodsName != null and order.goodsName != ''">
                ,GOODS_NAME = #{order.goodsName}
            </if>
            <if test="order.goodsCategroy != null and order.goodsCategroy != ''">
                ,GOODS_CATEGROY = #{order.goodsCategroy}
            </if>
            <if test="order.goodsQuantity != null and order.goodsQuantity != ''">
                ,GOODS_QUANTITY = #{order.goodsQuantity}
            </if>
            <if test="order.goodsPrice != null">
                ,GOODS_PRICE = #{order.goodsPrice}
            </if>
            <if test="order.amount != null">
                ,AMOUNT = #{order.amount}
            </if>
            <if test="order.currency != null and order.currency != ''">
                ,CURRENCY = #{order.currency}
            </if>
            <if test="order.logisticsCompany != null and order.logisticsCompany != ''">
                ,LOGISTICS_COMPANY = #{order.logisticsCompany}
            </if>
            <if test="order.logisticsOrderNo != null and order.logisticsOrderNo != ''">
                ,LOGISTICS_ORDERNO = #{order.logisticsOrderNo}
            </if>
            <if test="order.resultCode != null and order.resultCode != ''">
                ,RESULT_CODE = #{order.resultCode}
            </if>
            <if test="order.usedFlag != null and order.usedFlag != ''">
                ,USED_FLAG = #{order.usedFlag}
            </if>
            WHERE 1 = 1
            <if test="item.id != null">
                AND ID = #{item.id,jdbcType=DECIMAL}
            </if>
            <if test="item.declareBatchNo != null and item.declareBatchNo != ''">
                AND DECLARE_BATCH_NO = #{item.declareBatchNo,jdbcType=VARCHAR}
            </if>
            <if test="item.orderNo != null and item.orderNo != ''">
                AND ORDER_NO = #{item.orderNo,jdbcType=VARCHAR}
            </if>
            <if test="item.subMemberCode != null and item.subMemberCode != ''">
                AND SUB_MEMBERCODE = #{item.subMemberCode}
            </if>
        </foreach>
    </update>