Hi,
This might work, but the requirement (as I understand it) is weird.
drop table target;
drop table source;
create table target (lc NUMBER, F1 NUMBER, F2 NUMBER, F3 NUMBER);
create table source (lc NUMBER, F1 NUMBER, F2 NUMBER, F3 NUMBER);
insert into target Values (1, 2, 3, 4);
insert into target Values (1, 5, 6, 7);
insert into target Values (2, 8, 9, 0);
insert into source Values (1, 3, 3, 1);
insert into source Values (1, 5, 5, 1);
insert into source Values (1, 7, 7, 1);
insert into source Values (2, 8, 8, 2);
insert into source Values (2, 9, 9, 2);
select * from target;
select * from source;
UPDATE target t set (f1, f2, f3) = (Select f1, f2, f3 FROM source s where t.lc = s.lc);
UPDATE target t set (f1, f2, f3) = (Select f1, f2, f3 FROM source s where s.rowid = (select MAX(ROWID) KEEP (DENSE_RANK FIRST ORDER BY ROWID) FROM source s2 WHERE t.lc = s2.lc));
select * from target;
rollback;
Table dropped.
Table dropped.
Table created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
LC F1 F2 F3
---------- ---------- ---------- ----------
1 2 3 4
1 5 6 7
2 8 9 0
3 rows selected.
LC F1 F2 F3
---------- ---------- ---------- ----------
1 3 3 1
1 5 5 1
1 7 7 1
2 8 8 2
2 9 9 2
5 rows selected.
UPDATE target t set (f1, f2, f3) = (Select f1, f2, f3 FROM source s where t.lc = s.lc)
Error at line 15
ORA-01427: ...
3 rows updated.
LC F1 F2 F3
---------- ---------- ---------- ----------
1 3 3 1
1 3 3 1
2 8 8 2
3 rows selected.
Rollback complete.