MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ADD & UPDATE

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
monaco
Beginner


Joined: 20 May 2004
Posts: 77
Topics: 31

PostPosted: Wed Sep 22, 2004 1:57 pm    Post subject: ADD & UPDATE Reply with quote

Hi all,

We wonder if you could help us with a DB2 problem.

We have a DB2 database that is a copy of of our master DB2 database. This copy can be changed by everybody, ie they can add values to a table, modify them or delete values from a table. Each week we authorize these changes and then want to extract them into the DB2 master. We retrieve all the rows that were added or updated (with a SELECT on the associated timestamp).
Our next step is to load this extract into the DB2 master (using RESUME YES). But rows that have been updated (the added rows load fine), would not load due to primary key violation ("duplicate primary key"). Is there any way to prevent this from happening and by loading the data also updating the rows in the DB2 master that have been updated in the DB2 copy, instead of them being discarded?

We are very grateful for any support, help or ideas you can give us, since we've been thinking over this problem for the last few weeks without finding a proper solution. Thank you very much for all your time and input!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Sep 22, 2004 5:53 pm    Post subject: Reply with quote

Monaco,

There are many ways to do it.

Approach 1:
Code:

1. Generate delete sql statements with commit after every 500 sql statemtnts for all updated keys.
2. Run the delete step prior to Loading
3. Now run the load utilty with RESUME yes option.

Check this link which discusses about generating and running dynamic sql statements.

http://www.mvsforums.com/helpboards/viewtopic.php?t=2787&highlight=commit


Approach 2: If the table volume is less than 5 million , then
Code:

1. LOAD replace will be a good option.

Approach 3:
Code:

1. Have the table unload prior to the changes
2. Have another unload of the table after all the changes.
3. Run a pgm/utility to compare and create a load file
4. Load Replace using the output from step3


Personally I prefer Approach 1 or 2.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
monaco
Beginner


Joined: 20 May 2004
Posts: 77
Topics: 31

PostPosted: Fri Sep 24, 2004 4:57 am    Post subject: Reply with quote

Thanks a lot.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group