Java通過Mybatis實現批量插入資料到Oracle中

灌南高手No1發表於2018-10-15

方法void insertMessages(List<BOMCMessage> list);

    <insert id="insertMessages" parameterType="java.util.List"  useGeneratedKeys="false">
        INSERT INTO ITF_OSMCS_SMS(
	        SMS_NO, SMS_NUM, SMS_TEXT, SMS_STATE, CURR_TIME, ALARM_ID, CREATOR, EMAIL, SMS_TITLE,
	        REAL_TIME, SMS_TYPE, SMS_SOURCE
        )
        <foreach collection="list" item="item" index="index" separator="union all">
	        select
	            #{item.smsNo,jdbcType=VARCHAR},
	            #{item.smsNum,jdbcType=VARCHAR},
	            #{item.smsText,jdbcType=VARCHAR},
	            #{item.smsState,jdbcType=DECIMAL},
	            #{item.currTime,jdbcType=TIMESTAMP},
	            #{item.alarmId,jdbcType=VARCHAR},
	            #{item.creator,jdbcType=VARCHAR},
	            #{item.email,jdbcType=VARCHAR},
	            #{item.smsTitle,jdbcType=VARCHAR},
	            #{item.realTime,jdbcType=TIMESTAMP},
	            #{item.smsType,jdbcType=VARCHAR},
	            #{item.smsSource,jdbcType=VARCHAR}
            from dual
        </foreach>
    </insert>

 

相關文章