Bypassing Automatic Record Locking with READ NOLOCK

Last reviewed: April 29, 1996
Article ID: Q95746
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

FoxPro automatically locks the record in the currently selected database as well as any related records in other work areas that are involved in a READ command. You can bypass the automatic record locking by using the READ NOLOCK command. Using this command may result in improved network performance when you are skipping through a database file.

MORE INFORMATION

Issuing a READ NOLOCK command bypasses automatic record locking. The record is displayed and the GET fields are enabled, but are read-only. Any controls, such as buttons, that use a field are disabled and cannot be chosen.

The record cannot be edited until SHOW GETS LOCK, LOCK(), or RLOCK() is issued. The record cannot be locked by using the shortcut key combination CTRL+O.

Issuing SHOW GETS without the LOCK clause will not allow the record to be locked, because SHOW GETS assumes the locking behavior of the READ command itself. Since the READ command has the NOLOCK clause, SHOW GETS will not lock the record.

SHOW GETS LOCK, LOCK(), and RLOCK() all attempt to lock the record in the current work area. SHOW GETS LOCK attempts to lock related records in other work areas as well. LOCK() and RLOCK() do not attempt to lock related records. If the record is locked by another user, FoxPro will return error 109.

If SET MULTILOCKS is OFF, the record lock will automatically be released when the record pointer is moved off the current record. If SET MULTILOCKS is ON, the record lock will not be released until the database is closed, the user exits FoxPro, or an UNLOCK command is issued.

To enable READ NOLOCK, SET EXCLUSIVE must be OFF.

To issue a READ NOLOCK command for a screen created through the FoxPro screen generator, check the READ NOLOCK check box in the generator options dialog box.

REFERENCES

"Commands & Functions," READ, SHOW GETS, LOCK(), RLOCK(), SET MULTILOCKS, SET EXCLUSIVE

"Developer's Guide," Multi-User section


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a multiuser
KBCategory: kbprg
KBSubcategory: FxprgMultiuser


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.