首先批量更新需要增加
数据库的链接必须加上但是数据库连接必须加上 allowMultiQueries=true 属性,不然会报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
批量导入语法
<insert id="addShareGroupCustomerData" parameterType="map">
insert into t_group_customer(i_gid,v_group_id,v_group_name,v_group_address,v_phone_num,i_group_insert_type_id_key,dtm_data_date,i_date_insert_userid_key,i_examine_state_id_key,i_data_flag,i_is_gx,v_qy_num,I_CUSTOMER_REGION)
values
<foreach collection="list" item="item" index="index" separator="union all" >
( #{item.I_GID} ,#{item.V_GROUP_ID} ,#{item.V_GROUP_NAME} ,#{item.V_GROUP_ADDRESS} ,#{item.V_PHONE_NUM} ,#{item.I_GROUP_INSERT_TYPE_ID_KEY} ,now() ,#{item.I_DATE_INSERT_USERID_KEY} ,0 ,1 ,#{item.I_IS_GX} ,#{item.V_QY_NUM} ,#{item.I_CUSTOMER_REGION} )
</foreach>
</insert>
批量更新语法
<update id="updateGroupCustomerDataByGroupId" parameterType="map">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update t_group_customer
<set>
v_phone_num=#{item.V_PHONE_NUM},v_group_address=#{item.V_GROUP_ADDRESS},
dtm_data_date=now(),i_date_insert_userid_key=#{item.I_DATE_INSERT_USERID_KEY},I_CUSTOMER_REGION = #{item.I_CUSTOMER_REGION},
i_data_flag = #{item.I_DATA_FLAG}
</set>
where v_group_name like concat('%', #{item.V_GROUP_NAME},'%') escape '/' and v_qy_num = #{item.V_QY_NUM}
</foreach>