首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Spring-JDBC实现BadSqlGrammarException,但不是在SQLDeveloper中

通过Spring-JDBC实现BadSqlGrammarException,但不是在SQLDeveloper中
EN

Stack Overflow用户
提问于 2012-04-20 15:31:23
回答 1查看 1.1K关注 0票数 2

在SQLDeveloper中使用以下查询测试merge一切正常:

代码语言:javascript
复制
merge into proj.person_registry pr 
using ( 
select null as id, 
'69696696553' as code, 
'TESTYMC' as name, 
'WHATEVER' as firstname, 
'M' as cl_gender, 
'E' as cl_status, 
null as birth_date, 
null as death_date, 
null as citizen_country_code, 
null as country_code, 
null as location_code, 
null as zip, 
'SOMETOWN' as aadress, 
null as date_updated, 
null as date_created, 
null as aadress_date 
from dual) t on (pr.code = t.code) 
when matched then update set 
pr.name                 = t.name, 
pr.firstname            = t.firstname, 
pr.cl_gender            = t.cl_gender, 
pr.cl_status            = t.cl_status, 
pr.birth_date           = t.birth_date, 
pr.death_date           = t.death_date, 
pr.citizen_country_code = t.citizen_country_code, 
pr.country_code         = t.country_code, 
pr.location_code        = t.location_code, 
pr.zip                  = t.zip, 
pr.aadress              = t.aadress, 
pr.aadress_date         = t.aadress_date 
when not matched then 
insert values (t.id, t.code, t.name, t.firstname, t.cl_gender, t.cl_status, t.birth_date, t.death_date, t.citizen_country_code, t.country_code, t.location_code, t.zip, t.aadress, t.date_created, t.date_updated, t.aadress_date);

但是,尝试在我的代码中使用jdbc执行它时,会抛出BadSqlGrammarException,原因如下: java.sql.SQLException: ORA-00900: invalid SQL语句

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-25 15:02:24

您可能已经准备好了,但是您可能需要转义查询中的单引号。

我还发现,在将查询传递给Oracle时,分号会使查询失败,并返回与Oracle错误代码完全相同的代码。

这可能和删除语句末尾的分号一样简单

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10242035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档