KSAM RECORD POINTERS [ KSAM/3000 Reference Manual ] MPE/iX 5.0 Documentation
KSAM/3000 Reference Manual
KSAM RECORD POINTERS
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 Points directly to a record in the data
Pointer file based on its chronological record number.
Procedures that use these pointers are either pointer-dependent or
pointer-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 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 | POINTER | POINTER- | POSITION OF POINTER AFTER |
| NAME | TYPE | DEPENDENT | EXECUTION OF PROCEDURE |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FFINDBYKEY | Logical | NO | Points to key whose value was specified in |
| | | | call. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FFINDN | Logical | NO | Points to key whose relative record number |
| | | | was specified in call. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FREADBYKEY | Logical | NO | Points to key whose value was specified in |
| | | | call. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FWRITE | Logical | NO | Points to key whose value is next in |
| | | | ascending key sequence to the key value in |
| | | | the record just written. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FPOINT | Chrono- | NO | Points to record whose relative record |
| | logical | | number was specified in call. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FREADDIR* | Chrono- | NO | Points to record whose relative record |
| | logical | | number was specified in call. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FREAD | Logical | YES | Pointer 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.) |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FSPACE | Logical | YES | Positioned forward or backward, in key |
| | | | sequence, the number of records specified |
| | | | in call. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FREMOVE | Logical | YES | Points to next key value, in ascending |
| | | | sequence, to the key value in the record |
| | | | just deleted. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FUPDATE | Logical | YES | Pointer 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. |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| FREADC | Chrono- | YES | Pointer remains positioned to the record |
| | logical | | 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.
MPE/iX 5.0 Documentation