Home » SQL & PL/SQL » SQL & PL/SQL » Insert or/and update
icon6.gif  Insert or/and update [message #252341] Wed, 18 July 2007 12:09 Go to next message
kham2k
Messages: 34
Registered: May 2007
Member
Greetings!!!

I got a table which I want to update or insert. Lets say the table has 300 records. I get a flat file in that I have 3 new records and 2 old/updated records. So, What will be the easiest way to insert the 3 new records and update the remaining two records.
I would like to clarify that its not fixed which column will be changed. So, I have to make it independent of any fix changes, otherwise merge would have done the magic. So the job will run every night and look for already existing records by and then will update or insert it accordingly.

Thanks for you time.
Re: Insert or/and update [message #252343 is a reply to message #252341] Wed, 18 July 2007 12:18 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
If you are receiving all the columns in your file, it might be easiest to delete the exisiting records and then insert them with the updated data.

Just one thought.

icon6.gif  Re: Insert or/and update [message #252347 is a reply to message #252341] Wed, 18 July 2007 12:24 Go to previous messageGo to next message
kham2k
Messages: 34
Registered: May 2007
Member
You are right but 300 is just an example. Table is huge so i think it won't be a good idea to delete and insert again also the file will only have few records like in example I told you that only 5 records will be there.

I hope this might clarify the problem. I appreciate your help.
Re: Insert or/and update [message #252354 is a reply to message #252341] Wed, 18 July 2007 12:38 Go to previous messageGo to next message
BlackSwan
Messages: 25033
Registered: January 2009
Location: SoCal
Senior Member
Who/what/how determines "new row"?
How are updates identified; which row, which column, what new value?
How many; which Oracle datatypes are accomodated by this change mechanism?
icon6.gif  Re: Insert or/and update [message #252356 is a reply to message #252341] Wed, 18 July 2007 12:42 Go to previous message
kham2k
Messages: 34
Registered: May 2007
Member
We have a column which is a pk and will not change at all. so we compare the that column lets say store_id, that how we find out that the record is new record or it already exist in table

Previous Topic: Drop objects
Next Topic: 'records delimited by' in external tables
Goto Forum:
  


Current Time: Sat Dec 03 11:59:48 CST 2016

Total time taken to generate the page: 0.04312 seconds