- 论坛徽章:
- 0
|
oracle9i起开始有merge into语句,非常方便,但近日我使用过程中发现一个问题,sql语句如下:
merge into test_m_ghsspxsmx@webpub c1
using (select substr(wfd6101,1, xsrq,wfd6119 ghsbm,wfd6104 hwbm,wfd6106 spbm,sum(decode
(wfd6102,'TH',-1*wfd6111t,'PT',-1*wfd6111t,wfd6111t)) xscb,sum(decode(wfd6102,'TH',
-1*wfd6112,'PT',-1*wfd6112,wfd6112)) jxsje,sum(decode(wfd6102,'TH',
-1*wfd6108,'PT',-1*wfd6108,wfd610 ) xssl from wfd061@scm_sl
where substr(wfd6101,1, ='20050101' and (wfd6102='LS' or wfd6102='CS' or wfd6102='JS' or wfd6102='TH' or wfd6102='PT')
group by substr(wfd6101,1, ,wfd6119,wfd6104,wfd6106) c2
on (c1.ghsbm=c2.ghsbm) and (c1.xsrq=c2.xsrq) and (c1.spbm=c2.spbm) and (c1.hwbm=c2.hwbm)
when matched then
update set c1.jxsje=c2.jxsje,c1.xscb=c2.xscb,c1.xssl=c2.xssl
when not matched then
insert (c1,ghsbm,c1.xsrq,c1.hwbm,c1.spbm,c1.xscb,c1.jxsje,c1.xssl)
values (c2.ghsbm,c2.xsrq,c2.hwbm,c2.spbm,c2.xscb,c2.jxsje,c2.xssl);
其中,@web_pub及@scm_sl均是远程数据库联接,但此语句执行报不能在此使用聚组(group by),如果merge into中的查询语句不使用group by 则ok,我想请问大家,merge into 在对远程数据库插入或更新数据时是否有在其查询语句中不能使用group by 的限制,如有,如何解决? |
|