代码改变世界

关于mybatis的 insert into select 命令未结束问题

2017-07-04 21:39  tlnshuju  阅读(5094)  评论(0编辑  收藏  举报

关于mybatis的 insert into select 命令未结束问题,最后以为是sql写错了,可是,在plsql运行又没问题。最后还是解决这个问题。

是设置问题。

### Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

原先的配置:

  <insert id="addHistoryByPostBatchno" parameterType="paramMap" >

改动了以后,加了
 useGeneratedKeys="false"

<insert id="addHistoryByPostBatchno" parameterType="paramMap" useGeneratedKeys="false" >
 	 Insert into 
	  Tb_Dispatch_Mail_History
	  (
		  mail_no, rec_name, rec_address, rec_telephone, 
		  customer_no, post_opter, mail_content_name, mail_weight,
		  actual_postage, delivery_area, post_time, post_condition,
	      post_status, post_batchNo, customer_id
	   ) 
	  select 
		   mail_no, rec_name, rec_address, rec_telephone, 
		   customer_no, post_opter, mail_content_name, mail_weight,
		   actual_postage, delivery_area, post_time, post_condition,
		   post_status, post_batchNo, customer_id 
	  from Tb_Dispatch_Mail_Post tp
  	<where>
  	 	  tp.post_batchno=#{paramMap.postBatchno}
  	</where>
  </insert>
  
 问题顺利解决,不在报错。假设你也遇到相同问题,请留言一起探讨,我也仅仅是攻克了问题而已。假设看到这里你攻克了问题。麻烦点赞吧!


官网的解释是
同意 JDBC 支持自己主动生成主键,须要驱动兼容。假设设置为 true 则这个设置强制使用自己主动生成主键,虽然一些驱动不能兼容但仍可正常工作(比方 Derby)。