Previous Topic: Disconnecting Records from Indexed SetsNext Topic: Lock Management


Retrieving Indexed Records

In contrast to locating member records of a chained set, CA IDMS/DB locates member record occurrences in an index by searching the index. CA IDMS/DB does not have to access each member record occurrence as with chain linkage.

Types of Processing

Because CA IDMS/DB searches the index rather than actual record occurrences, indexed sets provide a quick and efficient method for the following types of processing:

Example When Owner Pointers

Assume that the DEPT-EMPLOYEE set in the sample database is an indexed set sorted by employee identification number (EMP-ID-0415). To retrieve an occurrence of the EMPLOYEE record, a program might issue the following requests:

MOVE '0019' TO EMP-ID-0415.
OBTAIN CALC EMPLOYEE.
OBTAIN NEXT WITHIN DEPT-EMPLOYEE SET.

To fulfill the prior request, CA IDMS/DB performs the following processing:

Step 1

Using the value '0019' placed by the program in the EMP-ID-0415 field, obtains the EMPLOYEE record with an identification number of '0019'.

Step 2

Obtains the EMPLOYEE record with the next-highest identification number as follows:

  1. Finds the SR8 record pointed to by EMPLOYEE 19's index pointer.
  2. Searches the SR8 record for EMPLOYEE 19's db-key. If CA IDMS/DB finds EMPLOYEE 19's db-key, processing skips to Step 3. If CA IDMS/DB does not find EMPLOYEE 19's db-key, processing continues as follows:
    1. Decrements the SR8 record's orphan count by 1. If the orphan count is now 0, CA IDMS/DB erases the SR8 record if it is empty or rewrites it if it still contains entries.
    2. CA IDMS/DB searches the next SR8 record in the index until it finds the db-key. At this time, CA IDMS/DB updates the EMPLOYEE record's index pointer to point to the correct SR8 record.

      Note: CA IDMS/DB only updates pointers and the orphan count at this time if both the area that contains the SR8 records and the area that contains the EMPLOYEE records were readied in update mode.

Step 3

Obtains the EMPLOYEE record whose db-key is adjacent to current of set (that is, the next EMPLOYEE record).

Example When No Owner Pointers

If the EMPLOYEE record did not have owner pointers, a program could issue the following request to retrieve an occurrence of the DEPARTMENT record:

MOVE '0019' TO EMP-ID-0415.
OBTAIN CALC EMPLOYEE.
OBTAIN OWNER WITHIN DEPT-EMPLOYEE SET.

When fulfilling the above request, the DBMS would discover the lack of an owner pointer in the set and use the EMPLOYEE record's index pointer to find the bottom-level SR8 record that contains the key for the requested EMPLOYEE record. CA IDMS/DB will then use the owner pointer contained in that SR8 record to obtain the DEPARTMENT record.

SR8 Record Currency

When a program uses a subschema that contains records in an indexed set, CA IDMS/DB changes SR8 record currency only when it accesses a member record through the index, since CA IDMS/DB keeps track of SR8 record currency internally. When CA IDMS/DB accesses a member record in any other manner, CA IDMS/DB does not change SR8 record currency.

For example, a program might issue the following commands:

MOVE '0019' TO EMP-ID-0415.
OBTAIN CALC EMPLOYEE.
OBTAIN NEXT WITHIN EMP-LNAME-NDX SET.

CA IDMS/DB then fulfills these requests as follows:

  1. Using the value '0019' for CALC entry into the database, CA IDMS/DB accesses the EMPLOYEE record with that identification number. EMPLOYEE 19 is now current of run unit, record, and the EMP-LNAME-NDX set. At this point, since CA IDMS/DB has not accessed an SR8 record, internal currency is not created for the SR8 structure of the index set.
  2. On OBTAIN NEXT, CA IDMS/DB accesses the SR8 record that contains the index entry for EMPLOYEE 19. At this time, CA IDMS/DB makes this SR8 record the current record of the SR8 structure of the index set.
  3. CA IDMS/DB finds the next index entry (either in that SR8 record or the next SR8 record). The SR8 record containing that index entry is now current of the SR8 structure.
  4. Using the next index entry, CA IDMS/DB obtains the corresponding EMPLOYEE record. That EMPLOYEE record is now current of run unit, record, and the EMP-LNAME-NDX.

RETURN and FIND Commands

When a program uses a subschema that contains records in an index, use: