qttzyz
2015-07-07 09:56
采纳率: 50%
浏览 10.8k

参数list对象结果如何使用mybatis批量插入数据

使用mybatis oracle,当传来的参数是list对象结果集,如何批量插入数据

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 丵鹰 2015-07-07 10:10
    已采纳

    图片说明

    1 打赏 评论
  • 丵鹰 2015-07-07 10:08


    <!--
    WARNING - @mbggenerated
    This element is automatically generated by MyBatis Generator, do not modify.
    -->

    <!--
    表的序列查询
    -->
    select TABLE_SEQ.NEXTVAL from DUAL

    </selectKey>
    insert into TABLE
     ( ID,
        NAME,
        PASSWORD,
        AGE,
        CREATETIME)
        select tableseq.NEXTVAL,a.* from (
        <foreach collection="list" item="item" index="index"
            separator="union all">
            select
            #{item.name,jdbcType=VARCHAR} as name,
            #{item.password,jdbcType=VARCHAR} as password,#{item.age,jdbcType=BECIMAL} as age,#{item.createTime,jdbcType=TIMESTAMP} as createTime
            from dual
        </foreach>
        ) a
    

    打赏 评论
  • Evankaka 2015-07-07 11:42


    INSERT ALL

    into TRX_BILL_DETAIL_INFO


    ID,


    CUST_NO,


    TRANS_CODE,


    TRANS_REFNO,


    TRANS_SEQNO,


    ORDER_NO,


    TRANS_AMT,


    BILL_DATE,


    BILL_FLAG,


    TRANS_DESC,




    #{item.id,jdbcType=DECIMAL},


    #{item.custNo,jdbcType=CHAR},


    #{item.transCode,jdbcType=CHAR},


    #{item.transRefno,jdbcType=CHAR},


    #{item.transSeqno,jdbcType=VARCHAR},


    #{item.orderNo,jdbcType=CHAR},


    #{item.transAmt,jdbcType=DECIMAL},


    #{item.billDate,jdbcType=DECIMAL},


    #{item.billFlag,jdbcType=CHAR},


    #{item.transDesc,jdbcType=VARCHAR},



    select 1 from dual

    
    
    打赏 评论

相关推荐 更多相似问题