By result set, I meant, why cannot Adabas return the result from a read statement in the order of descending or ascending
For ex:
READ CLASS-NAME BY NAME = ‘CCC’ DESCENDING returns
CCC
BBB
AAA
Instead, why can it not return,
KKK
CCC
May be its a stupid question, knowing well that adabas is not relational db. But still, why is it not possible?
Secondly, your answer to my question as quoted above, hints that Find creates a result set - what do you mean by this result set? How does it get created?
READ CLASS-NAME BY NAME = 'ZZZ' DESCENDING
ENDING AT 'CCC'
A short answer: Find creates a list of ISNs and stores it automatically in the WORK-area of ADABAS. The programmer is able to sort that ISN-List or make set operations with it.
Read is not that flexible, because it doesn’t create an ISN list. But therefore it’s better for mass data operations. For example: If you have to access all records of a file without a special sorting, it would be stupid to create a ISN-list of all records.
For more information please see the “Natural Programming Guide > Accessing Data in a Database > Accessing Data in an Adabas Database > Statements for Database Access”
There you can read more things about READ, FIND and HISTOGRAM
A rule of thumb is:
READ is for mass data operations
FIND is good for finding and sorting less records
The “=” is a synonym for the keyword FROM, and specifies a starting position within the index.
The ASCENDING and DESCENDING keywords are applied after positioning within the index, not after a set is created.
The meaning of
READ CLASS-NAME BY NAME = ‘CCC’ DESCENDING
is to position to the value CCC within the NAME index and read in descending sequence (i.e. from CCC to AAA). It does not mean “read from CCC to ZZZ and display in descending sequence.”
FIND does process a set. Operations, such as sorting and adding selection criteria, may be applied to an existing set.
I have written code to make use of ASC, DESC in the read statement. Ralph clearly wrote my thoughts. All I was trying to understand is why it is supposed to work this way. I know Adabas does things differently. I was trying to question it and understand.