Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Help: 8i merge/upsert/insert/update one table from another.
Note: I am a beginner. We currently use Oracle 8i at work.
I am trying to update table REG with the data from table REGTEMP. I
have tried a few methods that I found while searching the internet to
no avail. I believe it may be in part to a few issues.
1) both tables have the same layout. Columns are named the same and
same type.
2) the first 5 columns are used to create the primary key.
I am running in a Oracle 8i environment so it appears the merge command is not available.
Here is the last thing I tried:
UPDATE (SELECT REG.*, REGTEMP.* FROM REG, REGTEMP
WHERE REG.COL1 = REGTEMP.COL1, AND REG.COL2 = REGTEMP.COL2, AND REG.COL3 = REGTEMP.COL3, AND REG.COL4 = REGTEMP.COL4, AND REG.COL5 = REGTEMP.COL5) SET COL6 = COL6_1, COL7 = COL7_1, COL8 = COL8_1, COL9 = COL9_1;
INSERT INTO REG (SELECT * FROM REGTEMP WHERE NOT IN (SELECT REGTEMP.* FROM REG, REGTEMP
WHERE REG.COL1 = REGTEMP.COL1, AND REG.COL2 = REGTEMP.COL2, AND REG.COL3 = REGTEMP.COL3, AND REG.COL4 = REGTEMP.COL4, AND REG.COL5 = REGTEMP.COL5);
The update give me this error:
ORA-01779 cannot modify a column which maps to a non key-preserved
table.
Please note. I do not mind ditching the code used above. I believe there are easier ways of doing this. Also I would like to know the correct method to approach this task. I am open to any suggestions.
Thank you for your time,
Eric Received on Wed Mar 21 2007 - 07:34:36 CDT
![]() |
![]() |