mybatis-Oralce 中批量插入方法一:
<insert id="insertBatchSelective" parameterType="java.util.List" >
insert into tbl_epcc_txn (TXN_CD, EPCC_TXN_ID, TXN_DATE)
values
<foreach item="item" collection="list" separator="," >
(#{item.txnCd,jdbcType=VARCHAR}, #{item.epccTxnId,jdbcType=CHAR}, #{item.txnDate,jdbcType=CHAR})
</foreach>
</insert>
mybatis-Oracle 中批量插入方法二:
<insert id="insertBatchSelective" parameterType="java.util.List" useGeneratedKeys="false">
INSERT ALL
<foreach item="item" index="index" collection="list">
INTO tbl_epcc_txn
<trim prefix="(" suffix=")" suffixOverrides="," >
TXN_CD, EPCC_TXN_ID, TXN_DATE,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
#{item.txnCd,jdbcType=VARCHAR}, #{item.epccTxnId,jdbcType=CHAR}, #{item.txnDate,jdbcType=CHAR},
</trim>
</foreach>
SELECT 1 FROM DUAL
</insert>
测试sql:
insert all
into tbl_epcc_txn(EPCC_TXN_ID,TXN_CD) values('1','2017102410340796013842761770101')
into tbl_epcc_txn(EPCC_TXN_ID,TXN_CD) values('2','2017102410340796013842761770101')
into tbl_epcc_txn(EPCC_TXN_ID,TXN_CD) values('3','2017102410340796013842761770103')
select 1 from dual;