度量快速开发平台-专业、快速的软件定制快开平台
标题:
Oracle批量操作数据库
[打印本页]
作者:
fteair
时间:
2020-2-1 17:44
作者:
fteair
时间:
2020-2-5 17:48
作者:
fteair
时间:
2020-7-27 17:50
标题:
Oracle批量操作数据库
1:批量插入
<insert id="insertBatch" parameterType="Java.util.List" >
insert into RECIPEDETAIL (RDID, ROID, TYPE,
NAME, MEDIWEIGHT, MEDINUM,
MONEY, OPERATETIME, CHARGENUMBER,
REMARK, INSTRUCTION, AMOUNTEVERY,
MEDIUNIT, STATUS)
<!--序列oracle自增 -->
select SEQ_recipeDetail.NEXTVAL,A.* from(
<foreach collection="list" item="item" index="index" separator="union all">
select #{item.roid,jdbcType=DECIMAL}, #{item.type,jdbcType=DECIMAL},
#{item.name,jdbcType=NVARCHAR}, #{item.mediweight,jdbcType=DECIMAL}, #{item.medinum,jdbcType=DECIMAL},
#{item.money,jdbcType=DECIMAL}, #{item.operatetime,jdbcType=TIMESTAMP}, #{item.chargenumber,jdbcType=NVARCHAR},
#{item.remark,jdbcType=NVARCHAR}, #{item.instruction,jdbcType=NVARCHAR}, #{item.amountevery,jdbcType=DECIMAL},
#{item.mediunit,jdbcType=NVARCHAR}, #{item.status,jdbcType=DECIMAL}
FROM DUAL
</foreach>
) A
</insert>
2:批量更新
<update id="updateBatch" parameterType="java.util.List" >
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
update RECIPEDETAIL set
ROID = #{item.roid,jdbcType=DECIMAL},
TYPE = #{item.type,jdbcType=DECIMAL},
NAME = #{item.name,jdbcType=NVARCHAR},
MEDIWEIGHT = #{item.mediweight,jdbcType=DECIMAL},
MEDINUM = #{item.medinum,jdbcType=DECIMAL},
MONEY = #{item.money,jdbcType=DECIMAL},
OPERATETIME = #{item.operatetime,jdbcType=TIMESTAMP},
CHARGENUMBER = #{item.chargenumber,jdbcType=NVARCHAR},
REMARK = #{item.remark,jdbcType=NVARCHAR},
INSTRUCTION = #{item.instruction,jdbcType=NVARCHAR},
AMOUNTEVERY = #{item.amountevery,jdbcType=DECIMAL},
MEDIUNIT = #{item.mediunit,jdbcType=NVARCHAR},
STATUS = #{item.status,jdbcType=DECIMAL}
where RDID = #{item.rdid,jdbcType=DECIMAL}
</foreach>
</update>
复制代码
作者:
fteair
时间:
2020-7-27 17:51
作者:
张兴康
时间:
2020-7-28 17:30
作者:
fteair
时间:
2020-7-28 17:40
欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://p.delit.cn/)
Powered by Discuz! X3.2