<<

Contents

Search

>>

 

Record and file locking

 

When data records and Index Files are accessed in a multi-user operation, the consistency of files must be ensured. This can be reached by means of record and file locking. Usually all Index Files are opened in the multi-user mode. In the macro before Index-Open the access mode of Index Files can be specified by the instruction OPENMODE.

 

OPENMODE(<INDEX FILE>)

Meaning

0

Single user

 

When the Index File is accessed no data records are locked. Therefore this access mode may only be chosen if only one program accesses the data.

 

2

Multi-user exclusive

 

The Index File is opened exclusively. If an Index File cannot be opened exclusively, the program will be closed with an error report. While an Index File is being opened exclusively no other program can open the same Index File.

 

Any other value

Multi-user shared

 

This access mode applies to the multi-user operation where several programs access the Index File at the same time. Usually every read data record is unlocked again after it has been read (NOHOLDLOCK). With HOLDLOCK the data record remains locked to others until the data record is either rewritten (WRITE) or another data record of the Index File is read.

 

 

Whether deadlocks are detected depends on the operation system.

 

The programming language provides instructions for the individual control of record locking.

Data records can generally only be locked by being read. With HOLDLOCK the data record of the Index File that was read last is locked. Records written with WRITE are shared again after they have been written unless the instruction NOUNLOCK applies to the index file. The instruction NOUNLOCK has the effect that all read and written data records remain locked until the instruction UNLOCK is executed, which unlocks all locked data records of the Index File.

 

 

In the multi-user operation existing data records that are rewritten with WRITE must be read beforehand. If you try to write a data record with WRITE that has not been read before, the error 1062 will be reported. 

 

If a data record that is to be read is locked longer than 5 seconds, a message will be shown in the status line of the mask in intervals of 5 seconds respectively, which says for how many seconds the data record has been locked. The program waits until the data record is unlocked again or the key <Esc> is pressed. With <Esc> the access attempt is cancelled at the end of the next 5-seconds-interval and the error block ON ERROR … END of the respective READ instruction is executed.

 

With the command LOCKTIMEOUT the waiting time of 5 seconds can be changed.

 

With LOCKTIMEOUT = 0 the program waits endlessly until the data record is free. In this case there will not be a window on screen that reports that the data record is locked.

 

The switch DISABLE LOCKTIMEOUT has the effect that if a data record is locked the error code 1901 will appear after the first LOCKTIMEOUT interval is over and that no window will report that the data record is locked.

 

With NOREADLOCK the data records of an Index File are read without record locking, which means data records are not locked and can even be read if they are locked by another instruction.