View previous topic :: View next topic |
Author |
Message |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Fri May 11, 2007 11:09 am Post subject: Problem with Search All |
|
|
I want to write distinct values into the table. When I used the below piece of code I am still getting duplicate values inserted. Can some one help me where I am missing here.
My approach to do below is
1. search table if the value is available
2. If not update
SEARCH ALL DIAG-TABLE
AT END
ADD 1 TO DIAG-CT
SET DIAG-IDX TO DIAG-CT
MOVE DIAG-CD TO DIAG-CODE(DIAG-IDX)
MOVE DIAG-CT TO DIAG-POINTER(DIAG-IDX)
WHEN DIAG-CODE(DIAG-IDX) = SERVLINE-DIAG-CD
END-SEARCH.
Thanks,
Sriram |
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Fri May 11, 2007 11:16 am Post subject: |
|
|
Remove the "ALL" from the search command, once you start inserting rows in the table without regard to sequence, the binary search will produce unpredictable results.
If you just do a sequential search, you will always find the dups if they are there.
Alternately, you could use the binary search and do your inserting while keeping the table in sequence, but you would have to insert in the middle parts of the table most often. |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Fri May 11, 2007 1:01 pm Post subject: |
|
|
Thanks,
I changed to Search instead of Search all and it worked out
Regards,
Sriram |
|
Back to top |
|
 |
|
|