xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DbRLock()

Locks a record for write access.

Syntax

DbRLock( [<xRecno>] ) --> lSuccess

Arguments

<xRecno>
The parameter identifies a single record in a database. For DBF files, this is the numeric record number, as returned by Recno() for a particular record. It defaults to the current record.

Return

The return value is .T. (true) when the record <xRecno> is successfully locked, otherwise .F. (false) is returned.

Description

The DbRLock() function attempts to lock the record identified by <xRecno> in the current work area, and return .T. (true) if the record is locked.

If <xRecno> is not specified, all active record locks are removed and the current record is locked. When a particular record is specified with <xRecno>, the function places a lock on this record and adds it to the list of active record locks. This list can be retrieved with function DbRLockList().

Use DbRUnLock() to release locks from individual records.

Info

See also:DbRLockList(), DbRUnlock(), DbUnlock(), DbUnlockAll(), FLock(), NetRecLock(), RLock(), UNLOCK
Category: Database functions , Network functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example attempts to lock multiple records belonging to a
// transaction and unlocks all if a single lock is not successful

   PROCEDURE Main
      LOCAL cTransActID := "01234"
      LOCAL nCount      := 0

      USE Accounts INDEX Transact

      SEEK (cTransActID)

      DO WHILE FIELD->TRANSACTID == cTransActID
         IF DbRLock( Recno() )
            nCount ++             // successful lock
            SKIP                  // proceed to next record
         ELSE
            nCount := -1          // lock failed on this record
            DbRUnlock()           // release all previous locks
         ENDIF
      ENDDO

      IF nCount > 0
         <transaction code with locked records goes here>
      ENDIF

   RETURN

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