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. 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 thescript, 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.
lock all files .
lock file TABLENAME .
lock selected record [shared|exclusive] .
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.
lock file RESERVATIONS shared .
for MEMBERS with
( sum of RESERVATIONS TOTAL DUE > 3000) ;
LAST NAME ;
TOTAL DUE .
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, and (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.
for MEMBERS ;
lock selected record shared .
LAST NAME ;
TOTAL DUE ;
mean of RESERVATIONS TOTAL DUE .
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, and (3) for each record selected, list the member's LAST NAME, TOTAL DUE, and themean 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.