3.0用oracle执行多条sql报错,请支持
mapper.xml 中写法:<!-- 彻底删除机构,同时删除其对应的所有相关的数据 -->
<delete id="deleteDepart">
BEGIN
DELETE FROM sys_user_menu t WHERE t.user_id in(select id from sys_user where depart_id=#{departId});
DELETE FROM sys_depart_role t WHERE t.depart_id=#{departId};
DELETE FROM sys_user t WHERE t.depart_id=#{departId};
DELETE FROM sys_depart t WHERE t.id=#{departId};
END;
</delete>
报错信息:
==>Preparing: BEGIN DELETE FROM sys_user_menu t WHERE t.user_id IN (SELECT id FROM sys_user WHERE depart_id = ?); DELETE FROM sys_depart_role t WHERE t.depart_id = ?; DELETE FROM sys_user t WHERE t.depart_id = ?; DELETE FROM sys_depart t WHERE t.id = ?; END
==> Parameters: ff8080816e44382f016e49ab522e031a(String), ff8080816e44382f016e49ab522e031a(String), ff8080816e44382f016e49ab522e031a(String), ff8080816e44382f016e49ab522e031a(String)
2021-11-19 07:55:04.005 [1;31mERROR[0;39m [36mdruid.sql.Statement:149[0;39m - {conn-10004, pstmt-20012} execute error. BEGIN
DELETE FROM sys_user_menu t WHERE t.user_id IN (SELECT id FROM sys_user WHERE depart_id = ?);
DELETE FROM sys_depart_role t WHERE t.depart_id = ?;
DELETE FROM sys_user t WHERE t.depart_id = ?;
DELETE FROM sys_depart t WHERE t.id = ?;
END
java.sql.SQLException: ORA-06550: 第 6 行, 第 3 列:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.
看错误信息是最后end后面没有;结束,但源码上明明有中,请大家分析一下。
改为存储过程一样不行,报错如下:
### Error querying database.Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: { call delDept(? ) }
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: { call delDept(? ) }
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: { call delDept(? ) }
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: { call delDept(? ) }
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy134.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:89)
页:
[1]