Retrieval Sequence

In this section:

To determine the order of record retrieval, examine a diagram of the subtree. Use the CHECK FILE command to display the diagram:

CHECK FILE filename PICTURE

where:

filename

Is the name of the Master File.

The order of retrieval is from top to bottom, left to right. Only the first four fields of each segment are displayed.

For example, in the following figure, the first record in B is retrieved, then the first record in G, and all I records for the first G record. When all the G records and their descendant I records are retrieved, the first record in C is retrieved. Then all the D records for the first C are retrieved. When all the C records and their descendant D records are retrieved, the next record is B is retrieved and the process repeats itself.


Top of page

x
Retrieval Sequence With Unique Segments

The retrieval sequence for subtrees containing unique segments is still top to bottom, left to right, but the unique segments are treated as extensions of their parents. Records in a unique segment correspond one-to-one with the records in a parent. Records in a non-unique segment have a one-to-many correspondence. In cases where the parent segment has unique and non-unique descendants, the unique descendants are always retrieved first regardless of the left-to-right order.

To display a retrieval view of any subtree, use the CHECK FILE command with the RETRIEVE option:

CHECK FILE filename PICTURE RETRIEVE

A retrieval view shows which sort and IF criteria are valid. For sort phrases (BY or ACROSS), the segment containing the sort field must lie on the same path as the segments with all requested fields. That is, the segment with the BY or ACROSS field must be an ancestor or descendant of the segments containing the required fields.

For example, panel 1 in the following figure shows two descendant segments. The command PRINT B BY C is invalid, because the segments containing fields B and C do not lie on the same path. However, if the segment containing B is a unique segment, the two segments do lie on the same path. Panel 2 shows the retrieval view, and the command PRINT B BY C is valid.

The retrieval sequence for unique segments may also affect the results of COUNT or SUM commands. If a segment is the parent of a unique descendant, there is a one-to-one relationship. A COUNT command like COUNT A AND B returns identical results for each field, because the same record A is counted several times for each record B.

If the parent/descendant relationship is reversed with a non-unique parent, the result for field A is a greater number than the result for field B.


Information Builders