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

252 AppendixB
BASIC/V Intrinsics
BKREWRITE
BKREWRITE
Changes the contents of a record in a KSAM file.
CALL BKREWRITE (
filenum, status, parameterlist
)
A call to BKREWRITE replaces the contents of an existing record with new values. The record
to be rewritten is the last record accessed by a call to BKREAD, BKREADBYKEY,orBKSTART.To
use BKREWRITE, the file must be open in the access mode that allows update. If access is
shared, it must also be opened with dynamic locking allowed, and the file must be locked
by BKLOCK before records are rewritten.
Parameters
filenum
A numeric variable containing the file number that identifies the file. This
number was returned by the last call to BKOPEN. It should not be altered
unless the file is closed with a successful call to BKCLOSE. (
Required
parameter
)
status
A four-character string variable to which is returned a code that indicates
whether or not the call to BKREWRITE was successful and if not, why not.
The first character is set to zero if the call succeeds, to another value if not.
(
Required parameter
)
parameterlist
A list of variables or constants, separated by commas, that contains the
data to be written to the file replacing the last record read or written. The
total length of the new record is derived from the total number, data type,
and length in characters of each item in
parameterlist
. Although this
length need not be the same as the record it replaces, it should be long
enough to contain all the keys, but not exceed the defined record length.
(
Required parameter
)
Operation Notes
After calling BKREWRITE, you should always check the
status
parameter to make sure that
the rewrite was successful. Upon successful completion of BKREWRITE, new values replace
the data in the last record read to or written from the BASIC program. The new data may
change every value in the previously read record including the primary key value.
If you want to replace a record with a particular key value, you should locate and read the
record with BKREADBYKEY or BKSTART. To rewrite a series of records you should read the
records with BKREAD.
When the data in the
parameterlist
of BKREWRITE is shorter in total length than the data
in the record being rewritten, there is less total data in the rewritten record. In order to
maintain the key sequence of all keys, defined values should be written to the location of
all keys, both the primary key and any alternate keys.