-
起因 : 批量插入数据库表报错
-
代码演示 :
-
@Insert("<script> Insert ALL into table(字段1,字段2) values<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\"into table VALUES\">" (#{item},#{para})</foreach>SELECT 1 FROM DUAL" </script>") void insertAll(@Param("list") List<Integer> list ,@@Param("para") Integer para)
-
传入参数为List < Integer > list和Integer para , 报错提示ORA-00933:SQL命令未正确结束 , 看看了很久 , 感觉没问题 , 将console报错的sql放到数据库执行也没问题 .
-
后来网上查询了好多 , 看到说要设置useGeneratedKeys = false , 马上试了一下 , 就好了.
-
useGeneratedKeys
-
最后 , 正确写法 :
@Insert("<script> Insert ALL into table(字段1,字段2) values<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\"into table VALUES\">" (#{item},#{para})</foreach>SELECT 1 FROM DUAL" </script>") @Options(useGeneratedKeys, = false) void insertAll(@Param("list") List<Integer> list ,@@Param("para") Integer para)
数据库批量插入Insert ALL into报错ORA-00933:SQL命令未正确结束
最新推荐文章于 2025-02-28 23:22:30 发布