标签:
--mybatis 批量插入数据 --1、Oracle(需要测试下是否支持MySQL) < insert id ="insertBatch" parameterType="List" > insert into REAL_DATA_HW( M_LINE_NO,M_TIME,HW_NUM, VOL_A,VOL_B,VOL_C ) < foreach collection ="list" item ="item" index ="index" separator ="union all"> select #{obj.M_LINE_NO,jdbcType= VARCHAR },to_date(#{obj.M_TIME ,jdbcType= VARCHAR },‘yyyy-MM-dd hh24:mi:ss‘),#{obj.HW_NUM , jdbcType=DOUBLE }, #{obj.VOL_A ,jdbcType= DOUBLE },#{obj.VOL_B ,jdbcType= DOUBLE },#{obj.VOL_C ,jdbcType= DOUBLE } from dual </ foreach > </ insert > --2、MySQL < insert id ="insertBatch" parameterType="List" > <![CDATA[ insert into REAL_DATA_HW( M_LINE_NO,M_TIME,HW_NUM, VOL_A,VOL_B,VOL_C ) values ]]> < foreach collection ="list" item ="item" index ="index" separator =","> ( #{obj.M_LINE_NO},to_date(#{obj.M_TIME},‘yyyy-MM-dd hh24:mi:ss‘),#{obj.HW_NUM}, #{obj.VOL_A},#{obj.VOL_B},#{obj.VOL_C} ) </ foreach > </ insert >
标签:
原文地址:http://www.cnblogs.com/sallet/p/4236086.html