Binary search and duplicate records.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
RyanFox
Registered Member
Posts: 52
Joined: Sat Jun 15, 2013 12:54 pm

Binary search and duplicate records.

Post by RyanFox »

Hi,

With binary serch, why "duplication" of records is not possible? Please help.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Binary search and duplicate records.

Post 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.
zprogrammer
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1905
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa

Re: Binary search and duplicate records.

Post 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.
RyanFox
Registered Member
Posts: 52
Joined: Sat Jun 15, 2013 12:54 pm

Re: Binary search and duplicate records.

Post by RyanFox »

I did not get what you are trying to emphasize on Pandora??

Thanks Robert, your explanation helps.
Post Reply Previous topicNext topic

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”