定义的sql是:
merge into TXZH_ALL t1
using (select '333333' user_id,
'0401' systemid,
'20191012110400' updatetime,
'1' status,
'adsfgdfgsf' cmuser_id,
'cmcuseridno11' cmcuserid_no,
'张三2' user_name,
'' userext1,
'' userext2,
'' userext3
from dual) t2
on (t1.user_id = t2.user_id and t1.systemid = t2.systemid)
when not matched then
insert
values
(SEQ_TXZH_ALLID.nextval,
TO_DATE(t2.updatetime, 'YYYY-MM-DD HH24:MI:SS'),
t2.status,
t2.cmuser_id,
t2.cmcuserid_no,
t2.user_id,
t2.user_name,
t2.userext1,
t2.userext2,
t2.userext3,
t2.systemid)
when matched then
update
set t1.updatetime = TO_DATE(t2.updatetime, 'YYYY-MM-DD HH24:MI:SS'),
t1.status = t2.status,
t1.cmuser_id = t2.cmuser_id,
t1.cmcuserid_no = t2.cmcuserid_no,
t1.user_name = t2.user_name,
t1.userext1 = t2.userext1,
t1.userext2 = t2.userext2,
t1.userext3 = t2.userext3
数据库中直接执行没问题;
java代码:
String sqlStr = String.format(gotSql().toString(), userid, systemid, updatetime,status, cmuserid, cmcuseridno, username, userext1, userext2, userext3);
Sql sql = Sqls.create(sqlStr);
sql.forceExecQuery();
dao.execute(sql);
successSize++;
接口显示正常返回:
"data": {
"err_msg": "",
"err_code": "成功数据条数:1"
}
用的是druid-1.1.21.jar,后台没发现报错。但是会回滚数据,没有commit。
2019-11-14 10:40:00,891 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - merge into TXZH_ALL t1 using (select '333333' user_id,'0401' systemid,'20191012110400' updatetime,'1' status,'adsfgdfgsf' cmuser_id,'cmcuseridno11' cmcuserid_no,'张三2' user_name,'' userext1,'' userext2,'' userext3 from dual) t2 on (t1.user_id = t2.user_id and t1.systemid = t2.systemid) when not matched then insert values (SEQ_TXZH_ALLID.nextval,TO_DATE(t2.updatetime,'YYYY-MM-DD HH24:MI:SS'),t2.status,t2.cmuser_id,t2.cmcuserid_no,t2.user_id,t2.user_name,t2.userext1,t2.userext2,t2.userext3,t2.systemid) when matched then update set t1.updatetime = TO_DATE(t2.updatetime,'YYYY-MM-DD HH24:MI:SS'), t1.status = t2.status,t1.cmuser_id = t2.cmuser_id, t1.cmcuserid_no = t2.cmcuserid_no,t1.user_name = t2.user_name, t1.userext1 = t2.userext1, t1.userext2 = t2.userext2, t1.userext3 = t2.userext3