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

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

sql

3个回答

图片说明


<!--
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


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


Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐