SET LOCK Command

Enables or disables automatic file locking in certain commands.

SET LOCK ON | OFF

Parameters

  • ON
    Specifies that the commands listed below automatically lock the table when they execute. This provides read-only access to other users on the network and ensures that you are using the most current data.

  • OFF
    (Default) Enables shared access of tables with commands listed below. Use SET LOCK OFF if you don't need the most current information from a table.

Remarks

Visual FoxPro doesn't place a lock on a file when executing commands that require read-only access to a table. These commands include the following:

Commands

 

AVERAGE

JOIN (both files)

CALCULATE

LIST

COPY TO

LABEL

COPY TO ARRAY

REPORT

COUNT

SORT

DISPLAY (with a scope)

SUM

INDEX

TOTAL

While they are executed, these commands don't change the contents of a table, and access to the table is available to other users on the network. Thus, the table can be changed while you are executing one of these commands. For example, you might begin printing a report by using REPORT before another user changes a record included in the report. Your report now contains outdated information.

SET LOCK is scoped to the current data session.

See Also

Reference

FLOCK( ) Function

LOCK( ) Function

RLOCK( ) Function

SET DATASESSION Command

SET MULTILOCKS Command

SET Command Overview

Other Resources

Commands (Visual FoxPro)

Language Reference (Visual FoxPro)