I have this problem with PL/SQL. I have 2 tables with same columnus. One is for Current Run, the other for history.
At every run, I need to update history with just values that I found in current run.
Current Table
| ID |__NAME__|__SURNAME__|__CITY__|
| 10000 | ABC | CDE | IT |
| 10001 | EFG | ASD | EN |
| 10005 | | | |
History Table
| ID |__NAME__|__SURNAME__|__CITY__|
| 10000 | FFF | AAA | EN |
| 10001 | DDD | BBB | GR |
| 10005 | JKO | POI | GR |
| 10006 | DLK | MIN | IT |
As you can see, Current Table has a record with all empty values except ID=10005. So, I need to update history (name, surname, city) from current table where id exists in current table and name, surname and city are not null.
I've tried with
UPDATE HISTORY
SET (NAME, SURNAME, CITY) = (
SELECT NAME, SURNAME, CITY
FROM CURRENT temp
WHERE temp.name is not null and temp.id = history.id
)
WHERE exists (
SELECT NAME, SURNAME, CITY
FROM CURRENT temp
WHERE temp.name is not null and temp.id = history.id
);
But it doesn't work. I need to underline that when name is null in current table, then surname and city are also null.