Using KSAM/XL and KSAM 64 (32650-90886)

47
5 Reading File Data
KSAM files offer multiple record retrieval options using primary and alternate keys, and
logical and physical record numbers. The following list identifies the methods of reading
KSAM file data:
Sequential access:
By primary key.
By alternate key.
In physical record order.
Random access:
By key value.
By logical record number.
By approximate key match.
By partial key.
By physical record number.
KSAM uses two types of pointers to identify the location of records to be read: the logical
record pointer and the physical record pointer. The logical record pointer points to a key in
the index, which points to a data record. This pointer is used to locate records by key. The
physical record pointer points directly to a data record. This pointer is used to locate
records by their physical location in the file.
Intrinsics that use pointers are either pointer-dependent or pointer-independent.
Pointer-dependent intrinsics expect the pointer to be positioned in order to execute
correctly. Pointer-independent intrinsics execute regardless of where the pointer is
positioned.
KSAM maintains an advance flag to specify whether or not to advance the pointers before
the specific function. If the flag is set to TRUE, pointers are advanced before performing
the intrinsic function. If the flag is set to FALSE, the intrinsic function is performed
without advancing the pointers first.
Intrinsics have been developed to position pointers and to read records in sequence or
randomly, by key value and by record number. Table 5-1. identifies the intrinsics used to