merge into hy_wldw a
using (select * from jh_jk_order where TRANSID in('646','645')) b
on (a.dwno =b.SELLERID)
when matched then
update
set a.dwmc = b.sname,
a.dwlx = '2',
a.dz = b.saddress,
a.cs = decode(b.FROMDISTRICT, null, b.FROMCITY, b.FROMDISTRICT),
a.sf = b.FROMPROV,
a.lxr = b.sname,
a.dh = b.SMOBILEPHONE,
a.sjno = b.SELLERID,
a.yzbm = '1',
a.xtfl = '1'
when not matched then
insert
( dwmc, dwlx, dz, cs, sf, lxr, dh, sjno, yzbm, xtfl)
values
(
b.SNAME,
'2',
b.SADDRESS,
decode(b.FROMDISTRICT, null, b.FROMCITY, b.FROMDISTRICT),
b.FROMPROV,
b.SNAME,
b.SMOBILEPHONE,
b.SELLERID,
'1',
'1')
求找错!~~~~~~~
------解决方案--------------------
按照楼主提供的建表与merge语句,我在oracle库上进行了测试,merge语句可以正常执行,没有语法上的错误。如果是语句运行的结果不符合期望目标的情况,请楼主详细说明表中的相关数据及期望目标。