IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 load for a table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Fri Nov 15, 2013 7:13 pm
Reply with quote

Hi All,
I have a requirement to load a DB2 table (using the unload of the table from a previous date) using a batch job such that
1. The records from the table should be replaced with those from the
unload file
2. No other tables in the tablespace should be affected

I tried the below options with DSNUTILB but none seem to work for me
1. Replace - this deletes all the rows from other tables in the tablespace
2. Resume Yes - this adds up the records from the unload file to the table but does not delete the records in the table that are not in the unload file
3. Resume No (Default) - this does not work as the tablespace is not empty

Could any one suggest if this is possible and if so how. Thanks in advance.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Nov 15, 2013 7:36 pm
Reply with quote

1.How many records you wanted to load ?
2.How many records are in table?
3.How many tables are there in the tablespace?
4.Is there a extract of other tables in the tablespace?
5.What version of db2 are you using?
Back to top
View user's profile Send private message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Fri Nov 15, 2013 8:26 pm
Reply with quote

Pandora-Box wrote:
1.How many records you wanted to load ?
2.How many records are in table?
3.How many tables are there in the tablespace?
4.Is there a extract of other tables in the tablespace?
5.What version of db2 are you using?


Hi,
The number of records in the table and that i wanted to load can vary. Same is the case with the number of tables in the tablespace. Not sure how that would impact the processing. I am using DB2V7 for the current test.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Nov 15, 2013 9:04 pm
Reply with quote

one way is to
- truncate the table beforehand
- Load resume yes.

another is to
- unload all tables in the tablespace except the forementioned table.
- Load Replace the concatenated files
Back to top
View user's profile Send private message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Sun Nov 17, 2013 9:19 am
Reply with quote

GuyC,
Thanks for your valuable inputs.
Back to top
View user's profile Send private message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Mon Nov 18, 2013 6:52 pm
Reply with quote

Hi GuyC/All,
I am faced with another challenge here. Suppose i use a delete query to clean up the table under question (before load) it might delete rows from other tables as well due to referential constraint. Is there a way i can ensure the constraint is not enforced while deleting rows from a table?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Nov 18, 2013 7:51 pm
Reply with quote

Hello,

Suggest you reconsider your approach . . .

If the constraints are needed, they should probably Not be bypassed.
Back to top
View user's profile Send private message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Mon Nov 18, 2013 9:19 pm
Reply with quote

Hi,
This should not be a problem as the tables might be out of sync only for a brief period of time. After that, i will revert back the table contents to what it was before the load and they will become consistent again.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Nov 19, 2013 1:47 pm
Reply with quote

that's why I said truncate. It's not allowed when there is R.I.
Although it is not advisable you could drop the foreign key, do your thing and then recreate the foreign key. I 've seen processes who do this, but the problems are numerous and sometimes hard to solve.

In case of R.I. the second method is safer. although usually more CPU/Elapsed/space requirements.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts How to load to DB2 with column level ... DB2 6
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top