Updating a table from source - duplicate records exist in source
665881Oct 17 2008 — edited Oct 20 2008Hi All
I need logic to know how to update a target table from source. here the issue is source table contains duplicate data.
Oracle version is 10.2.0.3.0
OS - Sun Solaris
Target Table - Fields A,B and C. A and B are primary keys.
A B C
1 1
1 2
2 2
2 1
Source Table - No primary keys.
A B C
1 1 2
1 1 2
1 1 3
2 1 4
Based on fields A and B, column C needs to be updated from source table.
In the target table, 4th row should get updated to value 4.
In the target table - For first row, from source table, first 3 rows are matching. i am fine with any values (2,2,3).
In the target table - for second and third row, value of c should be null.
Currently I am updating this one through cursor. but it is taking lot of time.
In the production, less than one percent of records are duplicate records. I was asked to update the good records with regular update statement and duplicate records with cursor or some other logic. hence less than one percent records will be looped to cursor. basically management want to reduce load on cursor.
Your help is most appreciated.
Thanks