Previous Topic: Record StorageNext Topic: Clustering Records


Storing CALC Records

Stored On or Near Calculated Page

CA IDMS/DB stores records that have a storage mode of CALC on or near the page calculated from the record's CALC key (a schema-specified symbolic key). CA IDMS/DB uses the system-owned CALC set to keep track of all CALC records that randomize to a specific page. The CALC set's owner is the system-owned SR1 record type. The CALC set's members are all of the user records with a storage mode of CALC. The set is sorted in ascending sequence on the CALC key of each member record occurrence.

Example of a System-Owned CALC Set

The following diagram shows the system-owned CALC set for the sample employee database.

Note: The system-owned CALC set is an internal set. It should not be included in the user's schema or in structural diagrams.

One System-Owned CALC Set Per Database

There is one system-owned CALC set type per database; there is one CALC set occurrence for each page in the area. The CALC set is sorted in ascending sequence based on the CALC key of each member occurrence.

SR1 System Record

On a page that contains record occurrences, the SR1 record on a data page owns all CALC records that randomize to that page at store time, including records that end up on another page due to overflow conditions.

The following diagram shows the format and occurrences of the CALC set on page 7120 of the sample database. The CALC set for page 7120 includes all CALC records randomized to that page.

Note: DEPT 2000 belongs to the CALC set for page 7120 even though DEPT 2000 was actually stored on page 7121 (due to lack of space on its target page).

Retrieving a CALC Record

To retrieve a record occurrence stored CALC, CA IDMS/DB accepts from the user the value of the record's CALC key and calculates a page number from the key. CA IDMS/DB then enters this database page on the SR1 record and follows the page's CALC chain until either the requested record is located or a record of the same type with a higher key value is located; in the latter case, CA IDMS/DB returns an error status of 0326 (record not found) to the user.

Storing a CALC Record

In adding the DEPT 3100 record to page 7126, CA IDMS/DB creates a record prefix (shaded portion) that consists of pointers for the CALC set and for the DEPT-EMPLOYEE set. The prefix and data (as found in program variable storage) are positioned at the beginning of the free space. A line index is created at the end of the free space. The space available count is decremented, and the line space count is incremented.

Note: The CALC pointers in the SR1 record are updated to point to the DEPT 3100 record, while the CALC pointers in the DEPT 3100 record are set to point to the SR1 record. All other pointers in the DEPT 3100 record point back to the record itself because its DEPT-EMPLOYEE set occurrence is empty.

Storing Another CALC Record

The EMPLOYEE 23 record randomizes to and is stored on page 7026. The prefix of the EMPLOYEE 23 record supplies the following information: EMPLOYEE 23 (the only member of the CALC set on page 7008) and EMPLOYEE 19 are the only members of the DEPT-EMPLOYEE set for OFFICE 3100; EMPLOYEE 19 is next of set in the DEPT-EMPLOYEE set for DEPT 3100; all of the set occurrences that EMPLOYEE 23 owns are empty.