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

48 Chapter5
Reading File Data
Sequential Access by Primary Key
access files and identifies those pointers that are set by each.
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.
Sequential Access by Primary Key
Many processes retrieve records in a sequence, to systematically perform a function on
each record. The primary key sequence is usually used for such routines. The file opening
routine (an HPFOPEN or FOPEN intrinsic call) prepares for the most common record retrieval
method by positioning the pointers at the record containing the lowest value of the
primary key. A call to the FREAD intrinsic, after the file is opened, reads the first record in
the primary key sequence.
After reading the first record, the logical record pointer remains in the same position. The
next FREAD repositions the logical pointer as well as the physical record pointer to the next
sequential record in ascending key sequence and reads the record. Although FREAD may
position both pointers, it uses the logical data pointer to locate the particular record. An
end-of-data condition occurs when the last logical record is passed. At this point, the CCG
condition code is set and returned to your process.
Table 5-1. Pointer and Advance Flag Settings for Reading
Intrinsic Reads Advance
Flag
Sets Pointer Sets Advance Flag Pointer
Dependant
FFINDBYKEY no both no no
FFINDN no both no no
FPOINT no both no no
FREAD yes both yes yes
FREADBYKEY no both no no
FREADC yes PHYS yes yes
FREADDIR no PHYS yes no
FSPACE yes both no yes