HPlogo Using KSAM XL and KSAM 64 > Chapter 6 Writing and Updating Record Data

Writing New Records

MPE documents

Complete PDF
Table of Contents
Index

E0300 Edition 4 ♥
E0394 Edition 3

The FWRITE intrinsic writes new records to a new or existing file from a buffer in your program. Index entries for primary and alternate keys are entered automatically for each record written.

Depending on how the file was created, records may be written in random or sequential order. If the REUSE option is specified, each record is written to the next available space. If the NOREUSE option is specified, all records are written at the end of the file.

Records written to an existing file either overwrite existing records or are appended to existing records. This is determined by the access option of the aoptions parameter, selected in the HPFOPEN or FOPEN intrinsic call.

Following each write procedure, the logical record pointer is positioned at the next sequential record in key sequence or at the end-of-file marker. When the physical bounds of either the data area or index area of the file is reached, a CCG condition code is returned to your program.

Note that the control parameter of the FWRITE intrinsic must be included in the intrinsic call for compatibility. It has no meaning for KSAM files.

When writing records to a file that has shared access, file locking should be used. The HPFOPEN or FOPEN intrinsic call must allow dynamic locking. An FLOCK intrinsic should be included before pointers are positioned and records are written. Unlock the file using the FUNLOCK intrinsic when the write procedure is complete.




Chapter 6 Writing and Updating Record Data


Updating Existing Records