mybaties中语句为:
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";" >
update ID
<set>
id_type=${item.idType}
</set>
where id = #{item.id}
</foreach>
</update>
报错如下:org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: java.sql.SQLException: sql injection violation, class com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleBlockStatement not allow : begin
update ID
set
id_type='rr'
where id = 17
;
update ID
set
id_type='rs'
where id = 18
;end;
### SQL: begin update ID set id_type='rr' where id = 17 ; update ID set id_type='rs' where id = 18 ;end;
sql语句放到pl/sql 里可以直接用,为什么这里会报错啊,各位大神,有知道的吗?
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";" >
update ID
<set>
id_type=${item.idType}
</set>
where id = #{item.id}
</foreach>
</update>
报错如下:org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: java.sql.SQLException: sql injection violation, class com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleBlockStatement not allow : begin
update ID
set
id_type='rr'
where id = 17
;
update ID
set
id_type='rs'
where id = 18
;end;
### SQL: begin update ID set id_type='rr' where id = 17 ; update ID set id_type='rs' where id = 18 ;end;
sql语句放到pl/sql 里可以直接用,为什么这里会报错啊,各位大神,有知道的吗?
没用这么高端的技术,猜了一下可能是如下原因:1、表名叫ID,字段名也叫id,这个ID是oracle关键字,虽然说可以这么搞,但是谁知道加上你这个技术以后会不是有问题,你可以试试换个表名,换个字段名。
2、看看是不是事务处理的配置有问题。
除了这两个,,,其他想不到了。
是传来一个list参数,根据这个list更新表里的数据看网上别人说foreach是这么用的,我的就报错,没找到原因
是传来一个list参数,根据这个list更新表里的数据看网上别人说foreach是这么用的,我的就报错,没找到原因
begin
update ID
set
id_type='rr'
where id = 17
;
update ID
set
id_type='rs'
where id = 18
;end;
set id_type= decode(id,18,'rs',17,'rr')
where id in (18,17)这样的;