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

hb_FUnlock()

HB_FUNLOCK()

Unlocks part or all of any file

Syntax

      HB_FUNLOCK( <nHandle>, <nOffset>, <nBytes> )  --> <lSuccess>

Arguments

<nHandle> Dos file handle

set> Offset of the first byte of the region to be locked.

<nBytes> Number of bytes to be locked.

Returns

<lSuccess> .T. if the lock was removed, else .F.

Description

This function attempts to unlock a region of the file whose file handle is <nHandle>. This is a low level file function. To unlock Harbour data files use the DBUNLOCK() function.

The value of <nHandle> is obtained from either a call to the FOPEN() or the FCREATE() function.

<nOffset> is the offset (from the beginning of the file) to the first of the region to be unlocked. (Offsets from the current position nd of file are not currently supported.)

<nBytes> is the length of the region to be unlocked in bytes.

Examples

      refer to tfl.prg

Compliance

Harbour

Platforms

All (64K)

Files

Library is rtl

Seealso

HB_FLOCK(), FOPEN(), FCREATE(), FERROR(), FCLOSE(), DBUNLOCK()

C5_DBUNLOCK

 DBUNLOCK()
 Release all locks for the current work area
------------------------------------------------------------------------------
 Syntax

     DBUNLOCK() --> NIL

 Returns

     DBUNLOCK() always returns NIL.

 Description

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

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

 Notes

     .  Network environment: Releasing locks may cause updates to the
        database to become visible to other processes.  For more information,
        refer to the "Network Programming" chapter in the Programming and
        Utilities Guide.

 Examples

     .  The following example illustrates a basic use of the
        DBUNLOCK() function:

        cLast := "Winston"
        USE Sales SHARED NEW VIA "DBFNTX"
        DBSETINDEX( "LASTNAME" )
        //
        IF ( Sales->(DBSEEK(cLast)) )
           IF Sales->( RLOCK() )
              Sales->( DBDELETE() )

              ? "Record deleted: ", Sales( DELETED() )
              Sales->( DBUNLOCK() )
           ELSE
              ? "Unable to lock record..."
           ENDIF
        ELSE
           ? "Not found"
        ENDIF

 Files   Library is CLIPPER.LIB.

See Also: DBUNLOCKALL() 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]