Oracle中mybatis批量更新报错ORA-00933:SQL命令未正确结束

项目场景:

最近在开发项目的过程中遇见了这个问题:Oracle中批量更新的时候报错 ORA-00933:SQL命令未正确结束


问题描述

mybatis批量更新报错ORA-00933:SQL命令未正确结束

c 复制代码
<foreach item="item" index="index" collection="list" separator=";">
	update A
	set ID=#{item.id}
	where NAME=#{item.name}
</foreach>

上边这个执行的时候报错ORA-00933:SQL命令未正确结束


原因分析:

oracle中数据库批量更新和mysql中的有些不一样,需要进行如下修改。


解决方案:

对上边的代码进行改变

  1. separator=";" 这个里边一定要加分号,而不是逗号
  2. begin和end必须要成对出现 open="begin" end=";end;" 也就是为了补全语法
c 复制代码
<foreach item="item" index="index" collection="list"  open="begin" end=";end;"  separator=";">
	update A
	set ID=#{item.id}
	where NAME=#{item.name}
</foreach>
相关推荐
呆萌很1 小时前
达梦(DM8)数据库常用SQL
数据库·sql
跟太阳说早安1 小时前
极简数据库SQL
数据库·sql
yzs872 小时前
openGauss branch diff能力解析
数据库·oracle
郭小李2 小时前
spring中@Transactional注解对事务的支持
数据库·spring·oracle
凤凰院凶涛QAQ2 小时前
《MySQL内核拆解:从SQL到InnoDB》(三) : 数据库设计 & 聚合查询 & 分组查询
数据库·sql·mysql
Decay__3 小时前
01_MySQL 体系架构全解 —— 连接层、SQL 层、存储引擎层与 InnoDB 深入
运维·数据库·sql·mysql·架构
郭小李4 小时前
mybatis的 Mapper.xml语法
xml·java·mybatis
m0_639906944 小时前
MyBatis 实现分页查询|逻辑分页、物理分页、PageHelper 原理
mybatis
量子物理学5 小时前
oracle plsql instantclient 安装
数据库·oracle
captain37617 小时前
MyBatis操作数据库(入门2)
java·数据库·spring boot·后端·spring·mybatis