Locks a table.




The work area you want to lock.


Use FLOCK( ) to lock the table in the current work area, or in another specified work area, preventing others from using the table.

When you lock a table with FLOCK( ), only you can make changes to it. However, unlike USE...EXCLUSIVE and SET EXCLUSIVE ON, FLOCK( ) lets other users view the locked table while you are using it. When you lock a table with FLOCK( ), it remains locked until you issue UNLOCK or close the table.

FLOCK( ) is similar to RLOCK( ), except that FLOCK( ) locks an entire table, while RLOCK( ) lets you lock specific records of a table. Use FLOCK( ), therefore, when you need to have sole access to an entire table or related tables—for example, when you need to update multiple tables related by a common key.

FLOCK( ) can lock a table even if another user is viewing data contained in the table. FLOCK( ) is unsuccessful only if another user has explicitly locked the table or a record in the table, or is using a command that automatically locks the table or a record in the table. FLOCK( ) returns true if it is successful, and false if it is not.

All commands that change table data cause dBASE Plus to attempt an automatic record or file lock. If dBASE Plus fails to get an automatic record or file lock, it an error occurs. You might want to use FLOCK( ) to handle a lock failure youself, instead of letting the error occur.

When SET REPROCESS is set to 0 (the default) and FLOCK( ) can't immediately lock a table, dBASE Plus prompts you to attempt the lock again or cancel the attempt. Until you choose to cancel the function, FLOCK( ) repeatedly attempts to lock the table. Use SET REPROCESS to eliminate being prompted to cancel the FLOCK( ) function, or to set the number of locking attempts.

When you set a relation to a parent table with SET RELATION and then lock the table with FLOCK( ), dBASE Plus attempts to lock all child tables. For more information about relating tables, see SET RELATION.


Use the Rowset object’s lockSet( ) method.