yuan282828sc

导航

mybatis整合oracle 实现批量插入 备注?

<insert id="insertBatchReportFileInfo" parameterType="java.util.List">
    INSERT INTO report_file
       (report_file_id,
	    report_id,
	    file_uuid,
	    file_name,
	    file_dir,
	    file_type,
	    file_post_fix)
	SELECT SEQ_REPORT_FILE_ID.NEXTVAL report_file_id, A.*
	FROM(
	<foreach collection="list" item="reportFileInfo" index="index" separator="UNION ALL">
	 SELECT 
	       #{reportFileInfo.reportId,jdbcType=VARCHAR} report_id,
	       #{reportFileInfo.fileUuid,jdbcType=VARCHAR} file_uuid,
	       #{reportFileInfo.fileName,jdbcType=VARCHAR} file_name,
	       #{reportFileInfo.fileDir,jdbcType=VARCHAR} file_dir,
	       #{reportFileInfo.fileType,jdbcType=VARCHAR} file_type,
	       #{reportFileInfo.filePostFix,jdbcType=VARCHAR} file_post_fix
	     FROM dual
	   </foreach>
	   )A
</insert>
<insert id="insertWorkReport" parameterType="map">
	<selectKey keyProperty="reportId" resultType="java.lang.String" order="BEFORE">
		 select seq_work_report_id.nextval from dual  
	</selectKey>
	insert into work_report
	( report_id
	<if test="reportType != '' and  reportType != null">
		, report_type
	</if>
	<if test="completeContent != '' and  completeContent != null">
		, complete_content
	</if>
	<if test="needComplete != '' and  needComplete != null">
		, need_complete
	</if>
	<if test="needHelp != '' and  needHelp != null">
		, need_help
	</if>
	<if test="beginDt != '' and  beginDt != null">
		, begin_dt
	</if>
	<if test="endDt != '' and  endDt != null">
		,end_dt
	</if>
	<if test="createStaff != '' and  createStaff != null">
		,create_staff
	</if>
	, create_dt
	)
	values
	(seq_work_report_id.nextval
	<if test="reportType != '' and  reportType != null">
		, #{reportType}
	</if>
	<if test="completeContent != '' and  completeContent != null">
		, #{completeContent}
	</if>
	<if test="needComplete != '' and  needComplete != null">
		, #{completeContent}
	</if>
	<if test="needHelp != '' and  needHelp != null">
		, #{needHelp}
	</if>
	<if test="beginDt != '' and  beginDt != null">
		, #{beginDt}
	</if>
	<if test="endDt != '' and  endDt != null">
		,#{endDt}
	</if>
	<if test="createStaff != '' and  createStaff != null">
		,#{createStaff}
	</if>
	, sysdate
	)
</insert>

posted on 2018-03-30 09:45  丁园园  阅读(163)  评论(0)    收藏  举报