Setting and releasing locks

Setting and releasing record locks is controlled by three properties of the UniFile object:

  • The blocking strategy set by the UniFileBlockingStrategy property specifies whether to wait if the record is already locked (equivalent to a BASIC LOCKED clause).
  • The lock strategy set by the UniFileLockStrategy property specifies what kind of lock to set when reading.
  • The release strategy set by the UniFileReleaseStrategy property specifies when to release a lock, for example:
    • When a record is written or deleted.

    • When you set a new record ID value using the RecordID property. This provides a simple way to set the lock release strategy for a program that edits a sequence of records, without having to code lock handling every time a record is read or written.

    • Only by the UnlockRecord() method.

      Note: All locks are released when the session is closed.

You can set these properties for each file, or you can use the defaults associated with the UniSession object. These defaults are specified using the BlockingStrategy , LockStrategy, and ReleaseStrategy properties of the UniSession object. In either case the properties remain set for all subsequent reads on that file during the session; you do not need to set them again. For examples, see the entries for the UniFile and UniSession objects in A tour of the objects.