HPlogo Using KSAM XL and KSAM 64 > Chapter 5 Reading File Data

Chapter 5 Reading File Data

MPE documents

Complete PDF
Table of Contents
Index

E0300 Edition 4 ♥
E0394 Edition 3

Table of Contents
Sequential Access by Primary Key
Sequential Access by Primary and Alternate Key
Specifying the Record Number
Specifying a Key Value
Sequential Access by Partial Key Value
Random Access of a Single Record
Using a Key Value
Using the Relative Record Number
Using a Physical Record Number
Sequential Access in Physical Record Order
Shared File Access
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 "Pointer and Advance Flag Settings for Reading" identifies the intrinsics used to access files and identifies those pointers that are set by each.

Table 5-1 Pointer and Advance Flag Settings for Reading

Intrinsic Reads Advance Flag Sets Pointer Sets Advance Flag Pointer Dependant
FFINDBYKEYnobothnono
FFINDNnobothnono
FPOINTnobothnono
FREADyesbothyesyes
FREADBYKEYnobothnono
FREADCyesPHYSyesyes
FREADDIRnoPHYSyesno
FSPACEyesbothnoyes


NOTE: COBOL II and Business BASIC provide KSAM file access routines that read records by key value. Refer to your programming language manual for details.




Closing a KSAM File


Sequential Access by Primary Key