Previous Topic: Navigational DML Programming TechniquesNext Topic: Run Unit Currencies


DB-Keys and Page Information

Database Keys

Each database record occurrence is identified by a database key (db-key). The db-key is a 4-byte identifier that consists of:

The DBMS assigns a db-key to a record occurrence when the occurrence is stored in the database; that db-key remains unchanged until the occurrence is erased or the database is unloaded and subsequently reloaded.

Page Information

Page numbers are used to identify pages within a database; however, a page number is not necessarily unique across all areas accessible to a CA IDMS run-time system or even across all areas accessible to your run unit. If a page number is not unique, you can qualify it with additional information so that it uniquely identifies a page. The additional qualifying information is a 4-byte identifier that consists of:

A page group is a number assigned to an area by the DBA for the purpose of making the area's page range unique to the CA IDMS run-time system. The db-key radix indicates the number of bits within the 4-byte db-key that contain a record's line number. The db-key radix is calculated by CA IDMS based on the maximum number of record occurrences that can be stored on a page of the area.

For more information on page groups and maximum records per page, see the CA IDMS Database Administration Guide.

Qualifying Db-keys

Normally all areas accessed by a run unit have the same page information and so the db-key of a record occurrence uniquely identifies it from all other record occurrences accessible to the run unit. A run unit, however, can access areas with different page groups or db-key radixes if it accesses a database defined to allow mixed page group binds. When this happens, a db-key must be qualified either by record type or page information so that it uniquely identifies a record occurrence.

In order to permit qualification, either record type or page information can be specified when retrieving a record occurrence through its db-key. Whenever a record occurrence is retrieved, its record type, db-key and associated page information are returned to the application program in the IDMS communications block. You can save these for later use in retrieval commands. It is also possible to determine the page information associated with a specific record type by issuing an ACCEPT Page-Info command.

For more information on retrieving a record by db-key, see Accessing a Record by Its db-key.

For more information on saving qualifying information, see Saving Page Information.

For more information on mixed page group binds and accessing areas with different page groups or maximum records per page, see the CA IDMS Database Administration Guide.

Page Information and Record Types

For the duration of a run unit, the page information for all occurrences of a given record type is the same. Similarly, the page information for all record types within an area or all record types associated with a set is the same.

Using Page Information to Interpret Db-keys

The format of a db-key value depends on its db-key radix. The db-key radix specifies the number of bits within a db-key that are reserved for a record occurrence's line number. Since the db-key radix is part of the page information associated with a db-key, you can use page information to interpret a 4-byte db-key value. You can use this when displaying db-keys for error reporting purposes or when establishing a target page for storing records whose location mode is direct.

Given a db-key, you can separate its associated page number by dividing the db-key by 2 raised to the power of the db-key radix. For example, if the db-key is 4, you divide the db-key value by 2**4. The resulting value is the page number of the db-key. To separate the line number, you multiply the page number by 2 raised to the power of the db-key radix and subtract this value from the db-key value. The result is the line number of the db-key. You can use the following two formulas to calculate the page and line numbers from a db-key value: