Mybatis批量插入的资料,很多都是mysql的,insert into ... values (),(),...
oracle中不支持这种语法,oracle中的批量插入是酱紫insert into selcect ... union all select ...
[b]mysql[/b]
[b]oracle[/b]
oracle中不支持这种语法,oracle中的批量插入是酱紫insert into selcect ... union all select ...
[b]mysql[/b]
<insert id="addRoleModule" parameterType="java.util.List">
INSERT INTO T_P_ROLE_MODULE (ROLE_ID, MODULE_ID)
VALUES <foreach collection="list" item="item" index="index"
separator=",">
( #{item.roleId}, #{item.moduleId})
</foreach>
</insert
>
[b]oracle[/b]
<insert id="addRoleModule" parameterType="java.util.List">
INSERT INTO T_P_ROLE_MODULE (ROLE_ID, MODULE_ID)
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT #{item.roleId}, #{item.moduleId} FROM DUAL
</foreach>
</insert>