度量快速开发平台-专业、快速的软件定制快开平台

标题: Oracle批量操作数据库 [打印本页]

作者: fteair    时间: 2020-2-1 17:44

作者: fteair    时间: 2020-2-5 17:48

作者: fteair    时间: 2020-7-27 17:50
标题: Oracle批量操作数据库
  1. 1:批量插入
  2. <insert id="insertBatch" parameterType="Java.util.List" >
  3. insert into RECIPEDETAIL (RDID, ROID, TYPE,
  4. NAME, MEDIWEIGHT, MEDINUM,
  5. MONEY, OPERATETIME, CHARGENUMBER,
  6. REMARK, INSTRUCTION, AMOUNTEVERY,
  7. MEDIUNIT, STATUS)
  8. <!--序列oracle自增 -->
  9. select SEQ_recipeDetail.NEXTVAL,A.* from(
  10. <foreach collection="list" item="item" index="index" separator="union all">
  11. select #{item.roid,jdbcType=DECIMAL}, #{item.type,jdbcType=DECIMAL},
  12. #{item.name,jdbcType=NVARCHAR}, #{item.mediweight,jdbcType=DECIMAL}, #{item.medinum,jdbcType=DECIMAL},
  13. #{item.money,jdbcType=DECIMAL}, #{item.operatetime,jdbcType=TIMESTAMP}, #{item.chargenumber,jdbcType=NVARCHAR},
  14. #{item.remark,jdbcType=NVARCHAR}, #{item.instruction,jdbcType=NVARCHAR}, #{item.amountevery,jdbcType=DECIMAL},
  15. #{item.mediunit,jdbcType=NVARCHAR}, #{item.status,jdbcType=DECIMAL}
  16. FROM DUAL
  17. </foreach>
  18. ) A
  19. </insert>
  20. 2:批量更新
  21. <update id="updateBatch" parameterType="java.util.List" >
  22. <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
  23. update RECIPEDETAIL set
  24. ROID = #{item.roid,jdbcType=DECIMAL},
  25. TYPE = #{item.type,jdbcType=DECIMAL},
  26. NAME = #{item.name,jdbcType=NVARCHAR},
  27. MEDIWEIGHT = #{item.mediweight,jdbcType=DECIMAL},
  28. MEDINUM = #{item.medinum,jdbcType=DECIMAL},
  29. MONEY = #{item.money,jdbcType=DECIMAL},
  30. OPERATETIME = #{item.operatetime,jdbcType=TIMESTAMP},
  31. CHARGENUMBER = #{item.chargenumber,jdbcType=NVARCHAR},
  32. REMARK = #{item.remark,jdbcType=NVARCHAR},
  33. INSTRUCTION = #{item.instruction,jdbcType=NVARCHAR},
  34. AMOUNTEVERY = #{item.amountevery,jdbcType=DECIMAL},
  35. MEDIUNIT = #{item.mediunit,jdbcType=NVARCHAR},
  36. STATUS = #{item.status,jdbcType=DECIMAL}
  37. where RDID = #{item.rdid,jdbcType=DECIMAL}
  38. </foreach>
  39. </update>
复制代码



作者: fteair    时间: 2020-7-27 17:51

作者: 张兴康    时间: 2020-7-28 17:30

作者: fteair    时间: 2020-7-28 17:40





欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://bbs.delit.cn/) Powered by Discuz! X3.2