UNLOCK

UNLOCK

Release file/record locks set by the current user

Syntax

      UNLOCK [ALL]

Arguments

ALL releases all current locks in all work areas. If not specified, only the lock in the current work area is released.

Description

UNLOCK is a network command that releases file or record locks set by the current user. Use it when you want to release the current lock without setting a new lock. Both FLOCK() and RLOCK() release the current lock before setting a new one.

After an UNLOCK, an update to a shared database file and associated index and memo files becomes visible to DOS and other applications, but is not guaranteed to appear on disk until you perform a COMMIT or close the file.

Refer to the “Network Programming” chapter in the Programming and Utilities Guide for more information on the principles of locking and update visibility.

Notes

. SET RELATION: UNLOCK does not automatically release a record lock along a RELATION chain unless you UNLOCK ALL.

Examples

      .  This example attempts an update operation that requires a
         record lock.  If the RLOCK() is successful, the record is updated
         with a user-defined function and the RLOCK() is released with UNLOCK:

      USE Sales INDEX Salesman SHARED NEW
      IF RLOCK()
         UpdateRecord()
         UNLOCK
      ELSE
         ? "Record update failed"
         BREAK
      ENDIF

Seealso

DBUNLOCK(), DBUNLOCKALL(), FLOCK(), RLOCK(), SET RELATION

Harbour All Functions – D

Date()
Day()
Days()

DaysInMonth()
DaysToMonth()

dbAppend()
dbClearFilter()
dbCloseAll()
dbCloseArea()
dbCommit()
dbCommitAll()
dbCreate()
dbDelete()
dbEval()
dbF()
dbFilter()
dbGoBottom()
dbGoTo()
dbGoTop()
dbReCall()
dbRLock()
dbRLockList()
dbRUnlock()
dbSeek()
dbSelectArea()
dbSetDriver()
dbSetFilter()
dbSkip()
dbSkipper()
dbStruct()
dbUnlock()
dbUnlockAll()
dbUseArea()

DecToBin()
DecToHexa()
DecToOctal()

Deleted()
Descend()
DevOutPict()
DirChange()
DirRemove()
DiskSpace()

DMY()
Do()
DoW()

DOY
DToC()

DToR
DToS()

dbUnlock()

DBUNLOCK()

Unlock a record or release a file lock

Syntax

      DBUNLOCK()

Description

This function releases the file or record lock in the currently selected or aliased work area. It will not unlock an associated lock in a related databases.

Examples

      nId := 10
      USE testid INDEX testid NEW
      IF testid->( DBSEEK( nId ) )
         IF testid->( RLOCK() )
            DBDELETE()
         ELSE
            DBUNLOCK()
         ENDIF
      ENDIF
      USE

Compliance

Clipper

Files

Library is rdd

Seealso

DBUNLOCKALL(), FLOCK(), RLOCK()

dbRLock()

DBRLOCK()

This function locks the record based on identity

Syntax

      DBRLOCK([<xIdentity>]) --> lSuccess

Arguments

<xIdentity> Record identifier

Returns

DBRLOCK() returns a logical true (.T.) if lock was successful

Description

This function attempts to lock a record which is identified by <xIdentity> in the active data set. If the lock is successful the function will return a logical true (.T.) value; otherwise a logical false (.F.) will be returned. If <xIdentity> is not passed it will be assumed to lock the current active record/data item.

Examples

      PROCEDURE Main()
         LOCAL x := 0
         USE tests NEW
         FOR x := 1 TO reccount()
            IF ! DBRLOCK()
               DBUNLOCK()
            ENDIF
         NEXT
         USE

Compliance

Clipper

Files

Library is rdd

Seealso

DBUNLOCK(), DBUNLOCKALL(), FLOCK(), RLOCK()

dbAppend()

 

DBAPPEND()

Appends a new record to a database file.

Syntax

      DbAppend( [<lLock>] ) --> NIL

Arguments

<lLock> Toggle to release record locks

Returns

DbAppend() always returns NIL

Description

This function add a new record to the end of the database in the selected or aliased work area. All fields in that database will be given empty data values – character fields will be filled with blank spaces, date fields with CTOD(‘//’), numeric fields with 0, logical fields with .F., and memo fields with NULL bytes. The header of the database is not updated until the record is flushed from the buffer and the contents are written to the disk.

Under a networking enviroment, DBAPPEND() performs an additional operation: It attrmps to lock the newly added record. If the database file is currently locked or if a locking assignment if made to LASTREC()+1, NETERR() will return a logical true (.T.) immediately after the DBAPPEND() function. This function does not unlock the locked records.

If <lLock> is passed a logical true (.T.) value, it will release the record locks, which allows the application to main- tain multiple record locks during an appending operation. The default for this parameter is a logical false (.F.).

Examples

      PROCEDURE Main()
         LOCAL cName := "HARBOUR", nId := 10
         USE test
         test->( dbAppend() )
         REPLACE test->Name WITH cName, test->Id WITH nId
         USE
         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

DBUNLOCK(), DBUNLOCKALL()

C5_DBUNLOCKALL

 DBUNLOCKALL()
 Release all locks for all work areas
------------------------------------------------------------------------------
 Syntax

     DBUNLOCKALL() --> NIL

 Returns

     DBUNLOCKALL() always returns NIL.

 Description

     DBUNLOCKALL() releases any record or file locks obtained by the current
     process for any work area.  DBUNLOCKALL() is only meaningful on a shared
     database in a network environment.  It is equivalent to calling
     DBUNLOCK() on every occupied work area.

     DBUNLOCKALL() performs the same function as the UNLOCK ALL command.  For
     more information, refer to the UNLOCK ALL command.

 Examples

     .  The following example marks a record for deletion if an
        RLOCK() attempt is successful, then clears all locks in all work
        areas:

        cLast := "Winston"
        USE Sales SHARED NEW VIA "DBFNTX"
        DBSETINDEX( "SALEFNAM" )
        DBSETINDEX( "SALELNAM" )
        //
        USE Colls SHARED NEW VIA "DBFNTX"
        DBSETINDEX( "COLLFNAM" )
        DBSETINDEX( "COLLLNAM" )
        //
        DBSELECTAREA( "Sales" )      // select "Sales" work area
        //
        IF ( Colls->(DBSEEK(cLast)) )
           IF Colls->( DELETED() )
              ? "Record deleted: ", Colls->( DELETED() )

              IF Colls->( RLOCK() )
                 Colls->( DBRECALL() )
                 ? "Record recalled..."
              ENDIF
           ENDIF
        ELSE
           ? "Not found"
           DBUNLOCKALL()            // remove all locks in
        ENDIF                        // all work areas

 Files   Library is CLIPPER.LIB.

See Also: DBUNLOCK() FLOCK() RLOCK() UNLOCK



C5 Networking Commands and Functions

DBUNLOCK() :

Release all locks for the current workarea

DBUNLOCK() --> NIL

DBUNLOCKALL() :

Release all locks for all workareas

DBUNLOCKALL() --> NIL

FLOCK() :

Lock an open and shared database file

FLOCK() --> lSuccess

NETERR() :

Determine if a network command has failed

NETERR([<lNewError>]) --> lError

NETNAME() :

Return the current workstation identification

NETNAME() --> cWorkstationName

RLOCK() :

Lock the current record in the active work area

RLOCK() --> lSuccess

SET EXCLUSIVE

Establish shared or exclusive USE of database files

SET EXCLUSIVE ON | off | <xlToggle>

UNLOCK :

Release file record locks set by the current user

UNLOCK [ALL]