0

My project uses Springboot and Mybatis, I use batch insert grammer to save data and I used an oracle database

<sql id="site_columns">
    ID, SITE_URL, BRM_HGSSITE_ID, BRM_SITE_STATUS, BPS_HGSSITE_ID, SITE_STATUS, OP_HGSSITE_ID, BILLING_PLATFORM, BLIS_EFFECTIVE_FROM,
    BLIS_EFFECTIVE_TO, BRM_EFFECTIVE_FROM, ISSUE_TYPE, COMMENTS, CSM_FIRST_NAME, CSM_LAST_NAME, CSM_EMAIL, CREATE_TIME
</sql>

<insert id="batchSaveVerifiedSitesFromFile" parameterType="siteSummaryInfoBean">
    INSERT INTO MR_VERIFIED_SITE_LIST(<include refid="site_columns"/>) VALUES
    <foreach collection="list" item="site" separator=",">
        (MR_VERIFIED_SITE_LIST_SEQ.nextval, #{site.webexurl}, #{site.brm_hgssiteid}, #{site.brm_sitestatus},
        #{site.bps_hgssiteid}, #{site.sitestatus},
        #{site.op_hgssiteid}, #{site.billingplatform,jdbcType=VARCHAR}, #{site.blis_effectiveFrom,jdbcType=DATE},
        #{site.blis_effectiveTo,jdbcType=DATE}, #{site.brm_effectiveFrom,jdbcType=DATE},
        #{site.issueType,jdbcType=VARCHAR}, #{site.comments,jdbcType=VARCHAR},
        #{site.csmfirstname,jdbcType=VARCHAR}, #{site.csmlastname,jdbcType=VARCHAR},
        #{site.csmemail,jdbcType=VARCHAR},
        greatest(nvl(#{site.blis_effectiveTo,jdbcType=DATE},sysdate),
        nvl(#{site.brm_effectiveFrom,jdbcType=DATE},sysdate)))
    </foreach>
</insert>

2
  • 2
    And what's the problem ? Commented Sep 29, 2017 at 7:37
  • Your error related to Oracle Database, please, provide executed query Commented Sep 29, 2017 at 8:06

2 Answers 2

1

Oracle does not support multi-row insert statements.

You can write an insert into ... select ... union all select ... statement as seen in a different answer.

This way in your foreach loop the separator will be union all and the loop body will be select ... from dual.

Sign up to request clarification or add additional context in comments.

Comments

0

The insert statement should be inside the foreach.

For example overwrite $sql variable in each loop in the code itself.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.