MyBatis-批量插入

一、MySql

<!-- 批量插入 -->
  <insert id="batchInsert" parameterType="java.util.List">
      insert into sd_survey_vs_insure
      values  
      <foreach collection="list" item="surveyVsInsure" separator="," index="index">
               (#{surveyVsInsure.id},#{surveyVsInsure.insuranceTypeId},#{surveyVsInsure.surveyId})
      </foreach>
  </insert>

二、Oracle

<!-- 批量添加 -->
<insert id="batchInsert" parameterType="java.util.List">

  INSERT INTO EC_ECUSER_ROLE(ECER_ID,ECER_ECCU_ID,ECER_ECRO_ID)
  SELECT
  SEQ_EC_ECUSER_ROLE.NEXTVAL AS ECERID,ECERECCUID,ECERECROID
  FROM (
    <foreach collection="list" item="ecerItem" separator=" UNION ALL ">
      SELECT #{ecerItem.ecerEccuId} AS ECERECCUID,#{ecerItem.ecerEcroId} AS ECERECROID FROM DUAL
    </foreach>
  )
</insert>

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试