Page 1 of 1

Binary search and duplicate records.

Posted: Tue Feb 18, 2014 11:49 am
by RyanFox
Hi,

With binary serch, why "duplication" of records is not possible? Please help.

Re: Binary search and duplicate records.

Posted: Tue Feb 18, 2014 3:08 pm
by zprogrammer
Hi,

Check here quoted from the Manual http://publibz.boulder.ibm.com/cgi-bin/ ... 0821081020
The results of a SEARCH ALL operation are predictable only when:

The data in the table is ordered in ASCENDING KEY or DESCENDING KEY order

The contents of the ASCENDING or DESCENDING keys specified in the WHEN clause provide a unique table reference.

Re: Binary search and duplicate records.

Posted: Tue Feb 18, 2014 7:32 pm
by Robert Sample
I think you misunderstand. It is very possible to generate a table with duplicate key values and use that table in a SEARCH ALL statement. What IBM tells you is that, if the keys are not ascending (or descending, depending upon the coding) -- and duplicate keys are definitely not ascending (nor descending) -- then you CANNOT be assured that the SEARCH ALL worked. It may return a wrong record, or it may fail to return a record even though the key is in the table.

Re: Binary search and duplicate records.

Posted: Wed May 21, 2014 2:38 pm
by RyanFox
I did not get what you are trying to emphasize on Pandora??

Thanks Robert, your explanation helps.