update a record on load

Reply

Join Date: Oct 2008
Posts: 17
Reputation: vimotaru is an unknown quantity at this point 
Solved Threads: 1
vimotaru vimotaru is offline Offline
Newbie Poster

update a record on load

 
0
  #1
Mar 10th, 2009
Hi

I'd like to know if is possible update a record when load a table. The update must be over a record with a primary key.

For example:

I have a record with: id|date_begin|date_end|data
2|02/03/2009|NULL|0

and I want that line to be update when a record like
2|02/03/2009|10/03/2009|56,7
comes.

Is it possible? Primary key is defined by id, date_begin.

What I want is an update instead a reject record.

Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 790
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 109
darkagn's Avatar
darkagn darkagn is offline Offline
Master Poster

Re: update a record on load

 
1
  #2
Mar 10th, 2009
Hi vimotaro,

Are you asking if you receive a record you want to update an existing one with the data in that received record? If so, you can do this quite easily by running a SELECT COUNT(*) statement and seeing if this returns 1. If it does, run your UPDATE statement.

If this wasn't what you were asking, please clarify your question for me and I will try to help further
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 17
Reputation: vimotaru is an unknown quantity at this point 
Solved Threads: 1
vimotaru vimotaru is offline Offline
Newbie Poster

Re: update a record on load

 
0
  #3
Mar 10th, 2009
umm that's the solution as I explained the problem... but I explained it bad. Sorry.

I've doing a periodic load of a file with about 3000 records. The problem is that the new files (each 2 hours I have a new file) have data with the same pk but different info.

I'm wondering if it's possible doing a PL/SQL or any method to update the old records with the new information, avoiding rejected records for unique constraint.

I think the only way is loading the data in a stage table and later load the real table with the processed data, deleting all records before, but I'd like to avoid the staging table and process the staging table twice (one for delete the old data from real table, and one for insert the new data).

Maybe that's the only way to do it, but I wonder if an easier way is possible.

Thanks!!! and sorry for my bad explanation.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,082
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 124
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: update a record on load

 
1
  #4
Mar 11th, 2009
For that you need to use a staging table and update the master table based upon data in the look up table.

You need to handle the code in a PL/SQL block.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC