View previous topic :: View next topic
|
Author |
Message |
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
All, Thanks for the replies. I am now checking for duplicates while loading it. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome - Thank you for the follow-up
d |
|
Back to top |
|
|
|