一、批量插入
1、oracle写法:
insert into b_dbgl_zaixcs (
zaixcsid, mingc, pingsyid, xinxid, fujid,
jieg, pingfjg, pingf, zhuangt, shic,
startriq, endriq, pingfriq, datr, pingfr, beiz
)
<foreach collection=”list” item=”item” index=”index” separator=”union all”>
(select #{item.zaixcsid,jdbcType=VARCHAR}, #{item.mingc,jdbcType=VARCHAR},
#{item.pingsyid,jdbcType=VARCHAR},#{item.xinxid,jdbcType=VARCHAR},
#{item.fujid,jdbcType=VARCHAR}, #{item.jieg,jdbcType=VARCHAR},
#{item.pingfjg,jdbcType=VARCHAR}, #{item.pingf,jdbcType=DECIMAL},
#{item.zhuangt,jdbcType=VARCHAR},#{item.shic,jdbcType=DECIMAL},
#{item.startriq,jdbcType=TIMESTAMP}, #{item.endriq,jdbcType=TIMESTAMP},
#{item.pingfriq,jdbcType=TIMESTAMP}, #{item.datr,jdbcType=VARCHAR},
#{item.pingfr,jdbcType=VARCHAR},#{item.beiz,jdbcType=VARCHAR}
from dual)
</foreach>
</insert>
2、mysql写法:
values
<foreach collection=”list” item=”item” index=”index” separator=”,” >
(#{item.fujId,jdbcType=VARCHAR},
#{item.relateId,jdbcType=VARCHAR},
#{item.relateTableName,jdbcType=VARCHAR},
#{item.fujLx,jdbcType=VARCHAR},
#{item.wenjlx,jdbcType=VARCHAR},
#{item.wenjm,jdbcType=VARCHAR},
#{item.fjmc,jdbcType=VARCHAR},
#{item.fujPath,jdbcType=VARCHAR},
#{item.createUserId,jdbcType=VARCHAR},
#{item.createUser,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.relateTableZiduan,jdbcType=VARCHAR},
#{item.contentType,jdbcType=VARCHAR},
#{item.zhuangt,jdbcType=VARCHAR}
)
</foreach>
二、批量删除
1、删除数组数组
<delete >
delete from emp where empno in
<foreach item=”empnoItem” collection=”array” open=”(” separator=”,” close=”)”>
#{empnoItem}
</foreach>
</delete>
2、删除list列表数据
<delete >
delete from emp where empno in
<foreach item=”item” collection=”list” open=”(” separator=”,” close=”)”>
#{item}
</foreach>
</delete>
3、删除查询到的数据
<delete >
delete from QIYDFBZ where BIAOZBID in(
SELECT biaozbid
FROM
B_DBGL_QIYDFBZ
CONNECT BY PRIOR FENXID = FUJID start WITH BIAOZBID = #{biaozbid,jdbcType=VARCHAR} )
</delete>
发表评论