<insert id="saveorupdateBatch" parameterType="java.util.List"> MERGE INTO table_name t1 USING ( <foreach collection="list" item="item" index="index" separator="union all"> select #{item.id,jdbcType=VARCHAR} ID, #{item.month,jdbcType=VARCHAR} MONTH , #{item.siteName,jdbcType=VARCHAR} SITE_NAME, #{item.siteCode,jdbcType=VARCHAR} SITE_CODE, #{item.siteId,jdbcType=VARCHAR} SITE_ID, #{item.supplierId,jdbcType=VARCHAR} SUPPLIER_ID, #{item.creator,jdbcType=VARCHAR} CREATOR, #{item.gmtCreate,jdbcType=TIMESTAMP} GMT_CREATE, #{item.sipNumber,jdbcType=VARCHAR} SIP_NUMBER, #{item.siteSipId,jdbcType=VARCHAR} SITE_SIP_ID, #{item.modifier,jdbcType=VARCHAR} MODIFIER, #{item.gmtModified,jdbcType=TIMESTAMP} GMT_MODIFIED, #{item.version,jdbcType=NUMERIC} VERSION from dual </foreach>) t2 ON ( t1.ID = t2.ID ) WHEN MATCHED THEN UPDATE SET t1.MONTH = t2.MONTH, t1.SITE_NAME=t2.SITE_NAME,t1.SITE_CODE=t2.SITE_CODE,t1.SITE_ID=t2.SITE_ID,t1.SUPPLIER_ID=t2.SUPPLIER_ID,t1.SIP_NUMBER=t2.SIP_NUMBER,t1.SITE_SIP_ID=t2.SITE_SIP_ID,t1.VERSION=t2.VERSION,t1.GMT_MODIFIED=t2.GMT_MODIFIED,t1.MODIFIER=t2.MODIFIER WHEN NOT MATCHED THEN INSERT <trim prefix="(" suffix=")" suffixOverrides=","> <include refid="Base_Batch_Column_List"/> </trim> VALUES ( SYS_GUID(), t2.MONTH, t2.SITE_NAME, t2.SITE_CODE, t2.SITE_ID, t2.SUPPLIER_ID,t2.CREATOR,t2.GMT_CREATE,t2.SIP_NUMBER,t2.SITE_SIP_ID,t2.MODIFIER,t2.GMT_MODIFIED,t2.VERSION) </insert>
oracle数据库使用mybatis批量插入或者新增
最新推荐文章于 2024-06-28 04:23:51 发布