| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Writes database and index buffers to disk.
DbCommit() --> NIL
The return value is always NIL.
The DbCommit() function writes all database and index buffers held in memory to disk. The function operates in the current work area, unless it is used in an aliased expression.
Memory buffers serve as cache for field variables and index values so that assignments to field variables become immediately visible to an application without any file I/O. When a database is open in SHARED mode, however, such changes are not visible to other applications in a multi-user environment until the changes are commited to disk.
| See also: | CLOSE, COMMIT, DbCloseAll(), DbCommitAll(), DbRUnlock(), DbUnlock(), NetCommitAll(), RLock() |
| Category: | Database functions |
| Source: | rdd\dbcmd.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example shows a typical coding pattern for updating records
// in a multi-user environment.
PROCEDURE Main()
LOCAL cLastName, cFirstName
USE Customer ALIAS Cust SHARED NEW
SET INDEX TO Cust01, Cust02
cFirstname := Cust->Firstname
cLastname := Cust->Lastname
@ 10, 10 SAY "First name" GET cFirstname
@ 11, 10 SAY " Last name" GET cLastname
READ
IF Updated() .AND. RLock() // obtain record lock
REPLACE Cust->Firstname WITH cFirstname
REPLACE Cust->Lastname WITH cLastname
DbCommit() // flush memory buffers
DbUnlock() // release record lock
ENDIF
CLOSE Cust
RETURN NIL
http://www.xHarbour.com