Functions and Directives

Function DbCommit() Foundation

Writes file buffers in a work area into the files.

Syntax
DbCommit() --> NIL
Return

The return value of DbCommit() is always NIL.

Description

Calling the database function DbCommit() causes all open file buffers (for DBF and Index files) in a single work area to be written into the respective files. This causes changed data in memory to be permanently saved on the hard drive or diskette. When the function is used without the alias operator, the file buffers for the current work area are written to the files.

Changes to the fields of a database file are initially copied into the file buffer (cache), meaning that data changes are not written immediately into the file. DbCommit() instructs the operating system to write the buffers into the files. This is especially meaningful in network applications, since changed data can only be visible to other work stations after it has been written into the file.

The command COMMIT or function DbCommitAll() can be used to write the file buffers of all work areas of the current work space to disk.

Examples
DbCommit()
// In the example, the data for a record is read 
// into memory variables and changed. After it is 
// changed, it is copied into the file buffer using 
// REPLACE. Finally it is written into the file with 
// DbCommit(). 

PROCEDURE Main 
   LOCAL cItemNo , cItem 

   USE InvItem INDEX ItemA, ItemB ALIAS Items NEW 
   cItemNo  := Items->ItemNo 
   cItem:= Items->Item 

   CLS 

   @ 10,5 SAY "Item number     :" GET cItemNo 


   @ 11,5 SAY "Item description:" GET cItem 

   READ 

   IF .NOT. Empty( cItemNo + cItem ) 
      REPLACE Items->ItemNo  WITH cItemNo  , ; 
              Items->Item    WITH cItem 
      Items->( DbCommit() ) 
   ENDIF 

   CLOSE Items 
RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.