Type
Processing Command

Purpose
The lock command is functional only when using DataEase on a LAN (local area network). The lock command prevents users from viewing, modifying, adding, or deleting data in forms and records being used by a report/procedure.
The lock command overrides the default Multi?User Locking Rules assigned by the database administrator. In order to override the default locking rules, the first statement of the script must be either lock all files or unlock all files. If neither of these commands appears at the start of the script, the default locking rules govern LAN functioning until a lock or unlock command appears in the script.
All lock and unlock commands are automatically terminated at the end of a script.

Syntax
lock all files .
lock file TABLENAME .
lock selected record [shared|exclusive] .

Usage
The lock all files command locks all tables referenced by the script. Users can view records in the locked tables but cannot add, delete or modify data in these tables.
The lock file command locks a specified table for the duration of the procedure or until the same table is specified in an unlock command. When an individual table or record is locked, you must also specify the type of lock (shared or exclusive). Shared lets other users view records in the locked table but prohibits those users from entering, modifying, or deleting records in that table. Exclusive prevents all access to the locked table, including viewing records.
The lock selected record command functions like lock file except it only locks the record that is currently being processed. When DataEase finishes processing a record, it is automatically unlocked. Use this command only within a for command loop (see Example 2). If you use it outside a for loop, no records are selected; therefore nothing is locked.

Example 1
lock file RESERVATIONS shared .
for MEMBERS with
(sum of RESERVATIONS TOTAL DUE > 3000) ;
list records
LAST NAME ;
TOTAL DUE .
end
This script tells DataEase: 1) Lock the RESERVATIONS table so other users can view records but cannot add, delete or modify RESERVATIONS records during the processing of this script. 2) Select all the MEMBERS records whose related RESERVATIONS records have a combined TOTAL DUE greater than $3000. 3) For each record selected, list the member's LAST NAME and TOTAL DUE.
Notice that locking the RESERVATIONS table during the processing of this report prevents other users from entering new records that might alter the sum of calculation field.
Example 2
for MEMBERS ;
lock selected record shared .
list records
LAST NAME ;
TOTAL DUE ;
mean of RESERVATIONS TOTAL DUE .
end
This script tells DataEase: 1) Select all the MEMBERS records. 2) Lock each record as it is selected so other users can view it but cannot add, delete or modify the record while it is being processed. 3) For each record selected, list the member's LAST NAME, TOTAL DUE, and the mean TOTAL DUE of all the related RESERVATIONS records.
In this example, all MEMBERS records can be modified except the record that is currently being processed.
For more information on DataEase LAN configuration and the Multi-User Locking Rules, see the Record Entry and Application Menu chapters in the User's Guide.