Simplicty and flexibility!


Command::

unlock


Parameters


Returns/Result


Examples


Reference

unlock

Type

Processing Command

Purpose

The unlock command is functional only when running DataEase on a LAN (Local Area Network). The unlock command unlocks locked tables or records allowing other users full access to the data.

Syntax

unlock all files .

unlock file TABLENAME .

unlock selected record .

Usage

The unlock all files command unlocks all tables referenced by the procedure. If unlock all files is the first statement in the script, the default locking rules are overridden and all data is locked by individual records. You may lock tables on a selective basis using the lock file command.

The unlock file command unlocks the specified table for the duration of the procedure, or until the same table is specified in a lock command. In a script that begins with a lock all files statement, the unlock file command lets you unlock tables selectively, while the other tables referenced by the script remain locked.

The unlock selected record command unlocks the record that is currently being processed. If the default locking rules are overridden by an unlock all files or unlock file command, DataEase automatically locks a record from the time it is selected for processing until the next record is selected. Often, significant processing not involving the locked record may take place. By using the lock and unlock selected record commands, you can reduce the amount of time a record remains locked.

LAN

The default LAN Multi-User Locking Options resolve conflicts that arise when users attempt to view, modify, or delete records in a table while data in that table is being accessed by a procedure. If another user is currently using a resource required by the unlock command, DataEase displays a Resource Conflict message. While this message is displayed, DataEase automatically tries to execute the command at brief intervals.

When the required resource becomes available, DataEase automatically resumes processing and executes the rest of the procedure.

Example

In order to override the default locking rules, the first statement of a 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 thescript. All lock and unlock commands are automatically terminated at the end of a script.

 

lock file RESERVATIONS shared .

 

for MEMBERS with ( sum of

RESERVATIONS TOTAL DUE > 5000) ;

lock selected record .

list records

LAST NAME ;

TOTAL DUE .

unlock selected record .

end

for MEMBERS with ( highest of

RESERVATIONS DEPARTURE DATE < 01/01/99 ) ;

delete records .

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 procedure, (2) select all the MEMBERS records whose related RESERVATIONS records have a combined TOTAL DUE greater than $5000, (3) lock each MEMBERS record as it is selected for further processing. For each record selected, list the member's LAST NAME and TOTAL DUE, and (4) after each record is listed, unlock the record before continuing to the next part of the script.

Locking the RESERVATIONS table at the start of this procedure prevents other users from entering new records that might alter the sum of calculation. Locking and unlocking each MEMBERS record as it is listed prevents the TOTAL DUE information from being modified by another user.

See Also


On the forum about unlock

On the blog about unlock


dg3_HelpView