mybatis使用merge根据条件插入或更新多条数据出错,请排错一下,谢谢 30
<insertid="addModuleBatch"parameterType="java.util.List">mergeintoT_MODULEmusing(<for...
<insert id="addModuleBatch" parameterType="java.util.List" > merge into T_MODULE m using ( <foreach collection="list" item="item" index="index" separator="," > (select #{item.moduleId,jdbcType=DECIMAL} as MODULE_ID, #{item.moduleName,jdbcType=VARCHAR} as MODULE_NAME, #{item.moduleAlias,jdbcType=VARCHAR} as MODULE_ALIAS, #{item.moduleRightBit,jdbcType=DECIMAL} as MODULE_RIGHT_BIT, #{item.moduleRemark,jdbcType=VARCHAR} as MODULE_REMARK, #{item.companyNum,jdbcType=VARCHAR} as COMPANY_NUM from dual) </foreach> ) n on (m.MODULE_RIGHT_BIT = n.MODULE_RIGHT_BIT) when not matched then insert (MODULE_ID, MODULE_NAME, MODULE_ALIAS, MODULE_RIGHT_BIT, MODULE_REMARK, COMPANY_NUM) values (n.MODULE_ID, n.MODULE_NAME, n.MODULE_ALIAS, n.MODULE_RIGHT_BIT, n.MODULE_REMARK, n.COMPANY_NUM}) when matched the update set m.MODULE_NAME = n.MODULE_NAME, m.MODULE_REMARK = n.MODULE_REMARK </insert>
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询