判断需要插入的数据是否存在,如果不存在就更新
"saveBatch" parameterType="java.util.List" >
MERGE INTO 表名 T
USING (
"list" item="item" index="index" separator="union" >
SELECT SYS_GUID() AS CODE,
#{item.createDate,jdbcType=VARCHAR} AS CREATE_DATE,
#{item.createBy,jdbcType=VARCHAR} AS CREATE_BY,
#{item.flagDel,jdbcType=CHAR} AS FLAG_DEL,
#{item.flagDisplay,jdbcType=CHAR} AS FLAG_DISPLAY,
#{item.sort,jdbcType=DECIMAL} AS SORT FROM DUAL
) T1
ON (T1./*判断数据是否重复的字段*/= T./*判断数据是否重复的字段*/ AND T1./*判断数据是否重复的字段*/ = T./*判断数据是否重复的字段*/)
/*数据存在*/
WHEN MATCHED THEN
UPDATE SET T./*需要更新的字段*/=T1/*需要更新的字段*/
/*数据不存在*/
WHEN NOT MATCHED THEN
INSERT
(CODE,CREATE_DATE,CREATE_BY,FLAG_DEL,FLAG_DISPLAY,SORT)
VALUES
(T1.CODE,T1.CREATE_DATE,T1.CREATE_BY,T1.FLAG_DEL,T1.FLAG_DISPLAY,T1.SORT)