0

I'm trying to insert a list of records to an Oracle 11g table. I tried the MyBatis syntax with foreach but it fails with ORA-00933: SQL command not properly ended exception when the list has more than one record.

The generated sql in this case looks like:

UPDATE CUSTOMER_T SET app_name = ?, start_date = ?, end_date = ? WHERE customer_id=? UPDATE CUSTOMER_T SET app_name = ?, start_date = ?, end_date = ? WHERE customer_id=?

Below is my the query in the mapper:

<update id="updateApplication" parameterType="com.test.mybatis.Application">

        <foreach item="ca" collection="customer.applications.applcation"
            open="" close="" separator="">
        UPDATE CUSTOMER_T
        SET app_name = #{ca.appName,jdbcType=VARCHAR},      
        start_date = #{ca.startDate,jdbcType=DATE,javaType=javax.xml.datatype.XMLGregorianCalendar},
        end_date = #{ca.endDate,jdbcType=DATE,javaType=javax.xml.datatype.XMLGregorianCalendar}
        WHERE
        customer_id=#{customer.info.customerid}
        </foreach>      
    </update>    

I appreciate if someone could identify the issue here.

Sandp
  • 87
  • 1
  • 8

0 Answers0