Oracle SSM批量插入
<insert id="saveZF" parameterType="java.util.List" useGeneratedKeys="false">
insert into t_transmit("ZF_ID","PT_ID","TO_DEPTID","FROM_DEPTID","SEND_TIME","STATUS","TYPE","FLAG","STATUSFLAG")
select * from (
<foreach item="item" index="index" collection="list" separator="UNION ALL">
select #{item.ZF_ID} "ZF_ID",#{item.PT_ID} "PT_ID",#{item.TO_DEPTID} "TO_DEPTID",#{item.FROM_DEPTID} "FROM_DEPTID",#{item.SEND_TIME}
"SEND_TIME",#{item.STATUS} "STATUS",#{item.TYPE} "TYPE",#{item.FLAG} "FLAG",#{item.STATUSFLAG} "STATUSFLAG" from dual
</foreach>
)
</insert>
使用时注意的问题:批量插入时,如果没有主键,一定要显式指定useGeneratedKeys为false,否则会报: SQL 命令未正确结束
Mybatis,oracle,ORA-00933: SQL 命令未正确结束