为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:dm8_20241011_x86_win_64
【操作系统】:Win11
【CPU】:Intel64 Family 6 Model 154 Stepping 3 GenuineIntel ~2300 Mhz
【问题描述】*:SpringBooot+mybatis plus,在1个update标签中有多条DDL时,报错“第1 行附近出现错误:不支持的语句类型”。
1)url配置:url: jdbc:dm://127.0.0.1:5236/?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
2)mapper.xml的内容:
<update id="xxx">
drop table if exists t1;
drop table if exists t2;
</update>
问题解决了。采用如下方式:
1)begin execute immediate end;封装成一个语句块
2)sql里有单引号时,再加一个单引号进行转义
3)例子:
<update id="myUpdate1">
begin
execute immediate 'drop table t1';
execute immediate 'update t2 set c1=''123'' where c2=''456''';
</update>