Previous Topic: Disconnecting RecordsNext Topic: Index Management


Retrieving Records

Walking a Set

A program using navigational DML or CA IDMS/DB in response to an SQL request can access all of the members of a chained set in the following manner: starting with the owner record occurrence, a program can use the next pointers to access each member occurrence in the chain until the program reaches the owner record again. Accessing members in a chain in this way is known as "walking a set."

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

MOVE '0050' TO DEPT-ID-0410
OBTAIN CALC DEPARTMENT.
OBTAIN NEXT WITHIN DEPT-EMPLOYEE SET.

Processing the Request

CA IDMS/DB processes this request as follows:

  1. Using the value '0050' placed by the program in the DEPT-ID-041 0 field, CA IDMS/DB obtains the DEPARTMENT record with an identification number of '0050'.
  2. CA IDMS/DB then finds the record occurrences pointed to by DEPARTMENT 50's next DEPT-EMPLOYEE pointer.

Retrieving an Owner

A program can issue the following request to retrieve an occurrence of the DEPARTMENT record associated with an employee:

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

Processing the Request

CA IDMS/DB processes this request as follows:

  1. Using the value '0019' placed by the program in the EMP-ID-0415 field, CA IDMS/DB obtains the EMPLOYEE record with an identification number of '0019'.
  2. If the DEPT-EMPLOYEE set has owner pointers, CA IDMS/DB uses the EMPLOYEE record's owner pointer to retrieve the owning DEPARTMENT.
  3. If the DEPT-EMPLOYEE set does not have owner pointers, CA IDMS/DB uses the EMPLOYEE record's next pointer to walk the set until it retrieves the owner occurrence (that is, an occurrence of the DEPARTMENT record type).