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

Searching a table for duplicates


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Wed Mar 18, 2009 5:46 am
Reply with quote

Hello,

I have got a table with say field A.
I need to search this table on field A, and if there are duplicates in column A, then I need to generate an error.

I am not sure, what the most efficient logic would.
Can someone pls advise ?

Thanks
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: Wed Mar 18, 2009 5:54 am
Reply with quote

Hello,

You need to post the definition of the table and explain how it is loaded.

If this is in a program, it should be a simple matter to check for duplicates while loading the table.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Wed Mar 18, 2009 5:58 am
Reply with quote

Hello,

The table looks like this

Code:
WT-003-TABLE
OCCURS 10 TIMES                                 
INDEXED BY WTX-003-A.                           
    20  WT-003-A       PIC X(009).


This is loaded in the program.
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: Wed Mar 18, 2009 6:38 am
Reply with quote

Hello,

Then each time a new value is being loaded into the table, look at the already loaded values and generate the error when a duplicate is encountered.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Mar 18, 2009 7:14 am
Reply with quote

ap_mainframes wrote:
I have got a table with say field A.
I need to search this table on field A, and if there are duplicates in column A, then I need to generate an error.
Normally, that is done while LOADing the table....
Quote:
I am not sure, what the most efficient logic would.
Can someone pls advise ?
Yes, but just what is the question????
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Mar 18, 2009 10:36 pm
Reply with quote

Since your table does not have an ascending or descending key, your best bet is to sort the table entries prior to loading them then compare current and previous entries while loading as already stated. You could also use a memory sort after the load which will make your "search for duplicates" much easier. Looking for duplicates in an unsorted table is tedious.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Fri Mar 20, 2009 8:45 am
Reply with quote

All, Thanks for the replies. I am now checking for duplicates while loading it.
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: Fri Mar 20, 2009 9:14 am
Reply with quote

You're welcome - Thank you for the follow-up icon_smile.gif

d
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 -> COBOL Programming

 


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 Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top