Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Searching a table for duplicates

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Searching a table for duplicates
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

Site Director


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

PostPosted: Wed Mar 18, 2009 5:54 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Mar 18, 2009 6:38 am    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Wed Mar 18, 2009 7:14 am    Post subject: Re: Searching a table
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Mar 20, 2009 9:14 am    Post subject: Reply to: Searching a table for duplicates
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us