KSAM/V

KSAM is an acronym for Keyed Sequential Access Method. KSAM/V pro vides a disc ￿le structure for organizing and accessing records in a ￿le according to the con tents of key ￿elds. It is Hewlett-P ackard's implementation of indexed sequen tial processing. KSAM/V allo ws you to access records in t wo ways:

Sequentially, according to a sequence de￿ned b y key values.

Randomly, by ￿nding the record that has a ￿eld matc hing a speci￿c key value. A KSAM ￿le consists of t wo associated MPE/iX ￿les:

A data ￿le containing all of the ￿le's data records

A key ￿le, containing one or more balanced trees that main tain primary and alternate logical sequences for the data records.

The data ￿le contains the actual data. It can consist of ￿xed-length or v ariable-length records. Each record in the data ￿le con tains one primary k ey ￿eld and may have a maximum of 15 alternate key ￿elds. Data records are stored in a KSAM ￿le in c hronological order (this is the order in which they were written to the ￿le), without regard to k ey sequence. In KSAM mode, you can specify standard access if y ou wish. In addition to KSAM mode, y ou can specify standard (NOKSAM) mode.

The associated k ey ￿le must be used to access the data records.

KSAM procedures add, delete, read, and update KSAM records and are callable from user applications.

KSAMUTIL allows y ou to manipulate, v erify, and analyze KSAM ￿les. Because KSAM ￿le structure is di￿eren t from MPE/iX ￿le structure, y ou cannot create a KSAM ￿le with the MPE/iX command :BUILD . You can rename it with the MPE/iX command :RENAME , but it is inadvisable because it destro ys the cross reference bet ween the data ￿le and the associated key ￿le. Therefore, it is extremely useful to ha ve KSAMUTIL commands that are designed to operate speci￿cally on KSAM ￿les and preserv e the proper cross referencing.

Figure 7-1 sho ws an example of building a KSAM ￿le.

Figure 7-1. Building a KSAM File

7-2 Data Management