I have 2 tables (with 92 columns) with same columns but with different data. PK is Report_NR and File_Number
Table1: Original_Report:
Report_Nr    File_Number    Time   Minute   Work_Hours  .........
--------------------------------------------------
1              1            3       2        6
2              1            5       1        8
3              1            2       4        7
Table2: Modified_Report:
Report_Nr    File_Number    Time   Minute   Work_Hours  .........
--------------------------------------------------
1              1            3       2        8
2              1            5       1        8
3              1            1       2        7
4              1            5       6        6
Now I want to search for new or modified data entered from Table 2 and then to update Table 1 to be same as Table 2. For example, in my case, for report_id 1 update only column with modified data: Work_Hours. So I need to update only this column,for report_id 2, data is same in both tables so no update needed, for 3rd row need to update only time and minute and for 4th row I will need to insert all columns.
With this select I have identified new rows and modified rows:
-- NEW ROWS
SELECT A.*, 'NEW'
FROM Modified_Report  A
LEFT JOIN Original_Report B ON B.ID = A.ID
UNION
-- MODIFIED ROWS
SELECT B.*, 'MODIFIED' 
FROM (
        SELECT * FROM Modified_Report 
        MINUS
        SELECT * FROM Original_Report 
    ) S1
INNER JOIN Original_Report B ON S1.ID = B.ID;
Here I found sme info with merge for update: update one table with data from another
but I need this with unknown number of columns to be updated: for a row I can have 2 columns that I need modified or 10 or 40. Also I will need what column(s) is/are modified, and how many changes found for each column.
Will be a solution to use a procedure or function or if you have another idea?
I used a Oracle DB with SQL Developer
 
    