HPlogo KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4 USING KSAM FILES IN SPL PROGRAMS

KSAM RECORD POINTERS

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

Certain KSAM procedures use pointers that indicate the current record position in the file.Depending on the procedure, either of two pointers may be used:

• Logical Record Pointer

Points to a key in the key file that identifies a particular record in the data file.

• Chronological Record Pointer

Points directly to a record in the data file based on its chronological record number.

Procedures that use these pointers are either pointer-dependent orpointer-independent. Pointerdependent procedures expect the pointer to be positioned in order to execute correctly. Pointerindependent procedures, on the other hand, execute regardless of where the pointer is positioned, and in most cases, they position the pointer. Because the position of the pointer is significant for pointer-dependent procedures, Table 4-2 “Positioning the Pointers” defines exactly where each pointer is located following successful execution of those procedures that either depend on or position the pointer.

Table 4-2 Positioning the Pointers

PROCEDURE

NAME

POINTER

TYPE

POINTER-

DEPENDENT

POSITION OF POINTER AFTER

EXECUTION OF PROCEDURE

FFINDBYKEYLogicalNOPoints to key whose value was specified in call.
FFINDNLogicalNOPoints to key whose relative record number was specified in call.
FREADBYKEYLogicalNOPoints to key whose value was specified in call.
FWRITELogicalNOPoints to key whose value is next in ascending keysequence to the key value in the record just written.
FPOINTChrono- logicalNOPoints to record whose relative record number was specified in call.
FREADDIR*Chrono- logicalNOPoints to record whose relative record number was specified in call.
FREADLogicalYESPointer remains positioned to key for the record just read; unless next call is to FREAD or to FUPDATE followed by FREAD, in which case, pointer is advanced to next key in sequence before the next FREAD reads the record. (This permits sequential reads and updates.)
FSPACELogicalYESPositioned forward or backward, in key sequence, the number of records specified in call.
FREMOVELogicalYESPoints to next key value, in ascending sequence, to the key value in the record just deleted.
FUPDATELogicalYESPointer remains positioned to key of the record just modified; unless any key value is changed, in which case, it points to next key in ascending sequence after the key in the modified record.
FREADCChrono- logicalYESPointer remains positioned to the record just read; unless next call is to FREADC, in which case, it points to next record in ascending chronological sequence.
* Except for FREADDIR, each of these procedures positions both pointers. That is, all procedures that position the logical pointer also position the chronological pointer, and all calls (except FREADDIR) that position the the chronological poiner also position the logical pointer.

 

(Refer to appendix B, Extra Data Segments With Shared Access, for details of how KSAM determines pointer position.)

SHARED ACCESS

The position of the record pointers is crucial during shared access because the pointers are maintained in separate control blocks (extra data segments) for each open file. Thus, if the same file is opened by different users, any user may change the key file structure by adding or deleting records so that other users' pointers become invalid. To avoid this problem, it is good practice to lock the file in a shared environment before calling a procedure that positions the pointer and leave the file locked until any pointer-dependent operation is complete. This means that you should lock the file, call a procedure that sets the pointer, and then call a procedure that reads the file sequentially or updates the file, and then unlock the file so other users may access it. Once the file is unlocked, no user should assume that his pointers will still be valid. Before using a pointer again, it must be re-established.

Feedback to webmaster