我有两个要在一组公用列上合并的表:
table1
project|supplies|part|ship|delivery
A1|B2|C3|01012018|02012018
A1|B3|C4|01022018|02022018
A2|B1|C1|01032018|02032018
和
table2
project|supplies|part|amount
A1|B2|C3|100
A1|B3|C4|200
A2|B1|C1|300
预期输出为:
project|supplies|part|amount|ship|delivery
A1|B2|C3|100|01012018|02012018
A1|B3|C4|200|01022018|02022018
A2|B1|C1|300|01032018|02032018
我尝试使用的代码如下,但是它引发了ORA-30926: unable to get a stable set of rows in the source tables
错误
MERGE INTO table2 t2
USING (select DISTINCT projects,supplies,part,ship,deliver FROM table1) t1
ON (t2.project = t1.project)
WHEN MATCHED THEN
UPDATE SET t2.ship = t1.ship,
t2.deliver = t1.delivery
WHERE t1.part = t2.part
AND t1.project = t2.project
AND t1.supplies = t2.supllies;
我也尝试过:
MERGE INTO table2 t2
USING table1 t1
ON (t2.project = t1.project
AND t2.part = t1.part
AND t2.supplies = t1.supplies)
WHEN MATCHED THEN
UPDATE SET t2.ship = t1.ship,
t2.deliver = t1.delivery;
但是会出现相同的错误