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()

dbUnlockAll()

DBUNLOCKALL()

Unlocks all records and releases all file locks in all work areas.

Syntax

      DBUNLOCKALL()

Description

This function will remove all file and record locks in all work area.

Examples

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

Compliance

Clipper

Files

Library is rdd

Seealso

DBUNLOCK(), 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()

dbCommitAll()

DBCOMMITALL()

Flushes the memory buffer and performs a hard-disk write

Syntax

      DBCOMMIT()

Description

This function performs a hard-disk write for all work areas. Before the disk write is performed, all buffers are flushed. open work areas.

Examples

      PROCEDURE Main()
         LOCAL cName := SPACE( 40 )
         LOCAL nId := 0
         USE test EXCLUSIVE NEW
         USE testid NEW INDEX testid
         //
         @ 10, 10 GET cName
         @ 11, 10 GET nId
         READ
         //
         IF UPDATED()
            APPEND BLANK
            REPLACE tests->Name WITH cName
            REPLACE tests->Id WITH nId
            IF ! testid->( DBSEEK( nId ) )
               APPEND BLANK
               REPLACE tests->Id WITH nId
            ENDIF
         ENDIF
         DBCOMMITALL()
         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

DBCLOSEALL(), DBCOMMIT(), DBUNLOCK()

dbCommit()

 

DBCOMMIT()

Updates all index and database buffers for a given workarea

Syntax

      DBCOMMIT()

Description

This function updates all of the information for a give, selected, or active workarea. This operation includes all database and index buffers for that work area only. This function does not update all open work areas.

Examples

      PROCEDURE Main()
         LOCAL cName := SPACE( 40 )
         LOCAL nId := 0
         USE test EXCLUSIVE NEW
         //
         @ 10, 10 GET cName
         @ 11, 10 GET nId
         READ
         //
         IF UPDATED()
            APPEND BLANK
            REPLACE tests->Name WITH cName
            REPLACE tests->Id WITH nId
            tests->( DBCOMMIT() )
         ENDIF
         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

DBCLOSEALL(), DBCOMMITALL(), DBUNLOCK()

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()