DB 与oracle 批量新增的写法
DB
public int batchInsertOrg(@Param(value = "list") List<Org> list);
<insert id="batchInsertJczdbOrg">
insert into DT_ORG(
org_code,
org_name
)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.org_code,jdbcType=VARCHAR},
#{item.org_name,jdbcType=VARCHAR}
)
</foreach>
</insert>
oracle
public int batchInsertJczdbEnterprise(@Param(value = "list") List<JczdbEnterprise> list);
<insert id="batchInsertJczdbEnterprise" parameterType="java.util.List">
insert into DT_JCZDB_ENTERPRISE(
code,
num_member,
org_type,
establish_date,
address,
social_num,
recursive_org
)
select A.* FROM (
<foreach collection="list" item="item" index="index" separator="UNION" >
SELECT
#{item.code,jdbcType=VARCHAR},
#{item.num_member,jdbcType=INTEGER},
#{item.org_type,jdbcType=INTEGER},
#{item.establish_date,jdbcType=DATE} ,
#{item.address,jdbcType=VARCHAR},
#{item.social_num,jdbcType=INTEGER},
#{item.recursive_org,jdbcType=VARCHAR} from dual
</foreach>
) A
</insert>