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 

Replace Duplicate rows using DB2 Load utility

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


Joined: 18 Feb 2010
Posts: 2
Topics: 1

PostPosted: Wed Feb 24, 2010 5:31 pm    Post subject: Replace Duplicate rows using DB2 Load utility Reply with quote

Hello,
Greetings to everyone!

I have a requirement where I need to load the data from flat file to DB2. I know I can use the DB2 utility DSNUTILB to do that. This utility give us three options to load data in DB2 table:
Option 1
LOAD REPLACE: This options deletes all the records from tablespace before performing bulk load on the target DB2 table.

Option 2
RESUME YES: This option expects the target table to be empty to perform the bulk load

Option 3:
RESUME NO: This is like appending data to target table. But this option will reject any records with duplicate keys.

My requirement is that I want to replace the record having duplicate keys. In case of duplicate keys, the file record should overwrite the record in target table.

Does anyone have any idea how to achieve this using DSNUTILB.

Thanks!
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Wed Feb 24, 2010 5:47 pm    Post subject: Reply with quote

Unload the table, match the unloaded data with the new data discarding duplicates, and then load the combined old/new data that has no duplicates.
_________________
All the best,

di
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 Feb 24, 2010 5:47 pm    Post subject: Reply with quote

nitink.c,

It depends on the volume of the records to be updated/replaced. If you have at least 50% updated records then you might want to consider LOAD REPLACE.

If you have only few hundreds of records to be updated, Use a program to Update the rows.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nitink.c
Beginner


Joined: 18 Feb 2010
Posts: 2
Topics: 1

PostPosted: Wed Feb 24, 2010 7:07 pm    Post subject: Thanks for Reply Reply with quote

Kolusu/Papadi, Thanks for the reply!

I have thought of both the options and the reason I am looking for Bulk load solution rather than program or 'unload-merge-load' is:
1. I have tables that contain tens of millions of rows
2. The number of records coming in flat file will be in thousands
3. I want to perfom the load on 40 tables

So, if I should write a program, there will be 40 programs required (or less depending on design but not less than 15).
Using unload-merge-load mechanism will be too costly on tables having rows > 20 millions.

If these is no bulk load solution at all, I know I will have to use one of the option that you have mentioned.

Has anyone here used DB2 Import utility on Z/OS installation? How it works?
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 Feb 24, 2010 7:15 pm    Post subject: Reply with quote

nitink.c,

If you have only few thousands of records to be updated you probably can generate UPDATE statements and run them via DSNUTILB

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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