Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
DB2 load utility(how to avoid duplicate records)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Nagendran

New User


Joined: 24 Jan 2007
Posts: 89
Location: USA

PostPosted: Sun Jul 29, 2007 5:58 pm    Post subject: DB2 load utility(how to avoid duplicate records)
Reply with quote

Hi,

I am using DB2 Load utility to load the records in to the DB2 DB.while loading i want to discard the duplicate records getting inserted into the DB.


Note:There is no primary key in the DB.

For eg: Say a record of length 50 bytes.i have to enforce constraints on these 50 bytes to check for duplicate.

anybody plz help me.........

Regards,
Nagu
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Sun Jul 29, 2007 6:15 pm    Post subject:
Reply with quote

Why not sort the input file first, and use the capabilities of the sort product to remove duplicate records.
Back to top
View user's profile Send private message
Nagendran

New User


Joined: 24 Jan 2007
Posts: 89
Location: USA

PostPosted: Sun Jul 29, 2007 7:02 pm    Post subject: Re: DB2 load utility(how to avoid duplicate records)
Reply with quote

thats not my prob....

The problem for me here is when i try to insert a record which is already in DB it should be discarded.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sun Jul 29, 2007 8:00 pm    Post subject:
Reply with quote

Write a program to check for existence in the table first. Or define a primary key across all fields in the table. I don't believe the load utility can perform any logic.
Back to top
View user's profile Send private message
SharathG

New User


Joined: 23 Jan 2007
Posts: 12
Location: India

PostPosted: Thu Aug 02, 2007 7:32 pm    Post subject:
Reply with quote

Hi,

The best option to load a table from a sequential dataset is to use a Load with Replace option. It will replace all the existing data in the table with data from the PS dataset. Here's the syntax: -
LOAD DATA LOG NO
REPLACE
NOCOPYPEND
DISCARDS 1
STATISTICS TABLE(ALL) INDEX(ALL)
INDDN SYSREC00
INTO TABLE <table_name>
(Columns)

You can add this in the Customized Load Control Card and use it while Loading.
Back to top
View user's profile Send private message
ashwinreddy

Active User


Joined: 16 Sep 2004
Posts: 106
Location: Hyderabad

PostPosted: Thu Aug 02, 2007 7:43 pm    Post subject:
Reply with quote

Hi,

We use Replace option to replace all the data in a tale space.

But not to eliminate the duplicates.

As per my knowledge we can't aviod the duplicates in Load Utility.

As other members suggested write program to aviod duplicates or a jcl to aviod the dulicates.

My knowledge may be limited, lets see from other memebrs.

Cheers
Ashwin
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Aug 02, 2007 8:16 pm    Post subject:
Reply with quote

Hello,

From 2 of your posts:
Quote:
The problem for me here is when i try to insert a record which is already in DB it should be discarded.

Quote:
Note:There is no primary key in the DB.


With no primary key, how would you identify a duplicate?

If you mean entire-record duplicates, i suppose you could unload the table, combine the new and the old records by sorting on the entire record length while discarding duplicates, and then load the output file back into the table.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Aug 02, 2007 8:21 pm    Post subject:
Reply with quote

Table access without a primary key will be fine on small tables, but if the table is bigger than a few thousand records, you are going to start to see poor performance without a primary key also.

There are very few reasons for not defining a primary key.
Back to top
View user's profile Send private message
Nagendran

New User


Joined: 24 Jan 2007
Posts: 89
Location: USA

PostPosted: Thu Aug 02, 2007 8:46 pm    Post subject: Re: DB2 load utility(how to avoid duplicate records)
Reply with quote

I got the solution from you....

Thanks for all.....
Back to top
View user's profile Send private message
Suryanarayana.tadala

New User


Joined: 03 Nov 2005
Posts: 43
Location: St.Louis

PostPosted: Fri Aug 03, 2007 12:21 am    Post subject:
Reply with quote

Nagendran..
Could you please elaborate us with the solution that you have !!
Back to top
View user's profile Send private message
Nagendran

New User


Joined: 24 Jan 2007
Posts: 89
Location: USA

PostPosted: Fri Aug 03, 2007 12:38 am    Post subject: Re: DB2 load utility(how to avoid duplicate records)
Reply with quote

Hi,

1)I wrote a query in QMF to identify the duplicate records,
after that i have moved that duplicate records to a file.

2)Then i wrote a program to delete all the duplicate records from the DB.

3)Next by using Load utility i have loaded the records in the file to
the DB.

thanks,
Nagu
Back to top
View user's profile Send private message
Suryanarayana.tadala

New User


Joined: 03 Nov 2005
Posts: 43
Location: St.Louis

PostPosted: Fri Aug 03, 2007 12:45 am    Post subject:
Reply with quote

Thanks...I was under the impression that you have some utlity which does all this !!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm
No new posts How to Use DebugTool CodeCoverage Uti... neo4u IBM Tools 0 Thu Jun 22, 2017 6:38 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us