Function DbAppend() Foundation

Creates a new record.

DbAppend( [<nLockMode>] ) --> NIL
If the value 1 is specified for <nLockMode> all existing record locks remain active when DbAppend() is called. Otherwise existing record locks are released prior to appending a new record to a database.

The return value of DbAppend() is always NIL.


The database function DbAppend() creates a new, empty record at the end of a database file. The record pointer is positioned on the new (last) data record, regardless of active filter or index conditions. When the functions is called without the alias operator, the new record is appended to the database open in the current work area.

The command APPEND BLANK can be used instead of DbAppend(). APPEND BLANK is only effective in the current work area.

Multi-user access: When the file is opened on a network or simultaneously by two Xbase++ applications on a single computer, DbAppend() automatically attempts to lock the new record. If the record cannot be locked, the append is not successful. A runtime error is generated which is caught by a default error routine and nothing in the file is changed. The default error handling routine handles this error by changing the value returned by NetErr() to .T. (true) and allowing the application to continue.

By default DbAppend() calls function RLock() to lock the new record. This releases all existing record locks. If the value 1 is passed, DbAppend() uses DbRLock() to lock the new record and all existing record locks remain active.

// In the example, data for a new record is first 
// input to memory variables and then an attempt is 
// made to create a new record. If it could be 
// created, the data is copied into the file. 

   LOCAL cItemNo := Space(10), cItem := Space(50) 

   USE InvItem INDEX InvItemA, InvItemB ALIAS Items NEW 

   @ 10,5 SAY "Item number     :" GET cItemNo 
   @ 11,5 SAY "Item description:" GET cItem 

   IF .NOT. Empty( cItemNo + cItem ) 
      IF NetErr() 
         ? "record could not be created" 
         REPLACE Items->ItemNo WITH cItemNo  , ; 
                 Items->Item   WITH cItem 



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.