BadSqlGrammarException через Spring-JDBC, но не в SQLDeveloper
С помощью следующего запроса в SQLDeveloper для проверки слияния все идет хорошо:
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: недопустимый оператор SQL
1 ответ
Решение
Вы, вероятно, уже учли это, но вам, возможно, придется избегать одинарных кавычек в запросе.
Я также обнаружил, что при передаче запроса в Oracle, в моем случае с SQL Server с использованием OPENQUERY, точка с запятой приводит к сбою запроса именно с этим кодом ошибки Oracle.
Это может быть так же просто, как удалить точку с запятой в конце оператора