How to convert Page and line number of DBKEY
search cancel

How to convert Page and line number of DBKEY

book

Article ID: 267849

calendar_today

Updated On:

Products

IDMS

Issue/Introduction

How to convert page number and line index of a DBKEY to hexadecimal format.

E.g.  With radix 6, page number 5081790, line index 20. 

Environment

Component: CA IDMS/DB 

Release: 19.0

Resolution

Almost every IDMS installation uses the default radix of 8, so that the page number fits neatly in the first three bytes of a dbkey and the line index is in the fourth byte. 

Decimal value of the dbkey = page-number * ( 2 ** radix ) + line index.

With above example 

page-number * ( 2 ** 6 ) + line index
page-number * 64 + line index

5081790 * 64 + 20 = 325234580.
 
Then convert 325234580 to hexadecimal: x'1362AF94'.

  • Two binary halfwords that represent the page information associated with  the last record accessed by the run unit.

PAGE-INFO is not changed if the call to the DBMS results in a non-zero status.

  • The first halfword (PAGE-INFO-GROUP) represents the page group number. The second halfword (PAGE-INFO-DBK-FORMAT) represents the db-key radix.

The db-key radix portion of the page information can be used in interpreting a db-key for display purposes and in formatting a db-key from page and line numbers. The db-key radix represents the number of bits within a db-key value that are reserved for the line number of a
record.

  • By default, this value is 8, meaning that up to 255 records can be stored on a single page of the area. Given a db-key, it is possible to  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 radix is 4,  divide the db-key value by 2**4. The resulting value is the page number of the db-key.

  • To separate the line number, 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 would be the line number of the db-key. The following two formulas can be used to
calculate the page and line numbers from a db-key value:

Page-number = db-key value / (2 ** db-key radix)

Line-number = db-key value - (page-number * ( 2 ** db-key radix))

For more information refer to   Database Keys