xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

RLock()

Locks the current record for concurrent write access in a work area.

Syntax

RLOCK() --> lIsLocked

Return

The function returns .T. (true) if the current record is successfully locked, otherwise .F. (false) is returned.

Description

The network function RLock() locks the current record in a work area for concurrent write access. If the record is successfully locked, it still can be read by other applications, but it can only be changed by the application which has obtained the record lock.

RLock() releases all pending record locks prior to attempting to lock the current record. If this attempt fails, the record is currently locked by another application in a network.

Record locks are required when a database is opened in SHARED mode and data must be written to the database file using the REPLACE command, or when the deleted flagof the current record is changed using DELETE or RECALL.

After the record is changed, the record lock must be released using UNLOCK or DbUnlock().

Info

See also:APPEND BLANK, DbRLock(), DbRLockList(), DbUnlock(), DbUseArea(), FLock(), SET EXCLUSIVE, UNLOCK, USE
Category: Database functions , Network functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates a typical coding pattern for updating a
// record in a networked environment.

   PROCEDURE Main
      USE Customer ALIAS Cust SHARED
      INDEX ON Upper( LastName+FirstName) TO Cust01

      SEEK "WALTERS"

      IF Found()
         IF RLock()
            REPLACE FIELD->Lastname WITH "Waters"
            DbUnlock()
         ELSE
            Alert( "Record is currently locked" )
         ENDIF
      ENDIF

      USE
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe