Click or drag to resize

DbAppend Function

Add a new record to a database file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.5
	lReleaseLocks AS USUAL


Type: Usual
A logical data type that, if TRUE, clears all pending record locks, then appends the next record.  
If FALSE, all pending record locks are maintained, and the new record is added to the end of the lock list.  
The default value is TRUE.

Return Value

Type: Boolean
TRUE if successful; otherwise, FALSE.  
If successfully added, each field in the record is set to the empty value for its data type, and the new record becomes the current record.
By default, this function operates on the database file in the currently selected work area.  
It can be made to operate on an unselected work area by specifying it within an aliased expression. DBAppend(TRUE) performs the same function as the APPEND BLANK command.  
For more information, refer to APPEND BLANK.
Tip Tip
Logical records:  DBAppend() does not respect logical visibility.  
That is, if the record is successfully added, it becomes the current record, regardless of any order or filter condition. Shared mode:  
For a shared database, DBAppend() automatically places a record lock on the new record.  
If the record cannot be locked, NetErr() is set to TRUE, indicating that the record was not added, and execution continues.
The following example appends a blank record, checks for a NetErr() condition, and updates the data:
 1DBUseArea(TRUE, "DBFNTX", "sales", "Sales", ;
 2                TRUE)
 3... <Statements>
 5IF !NetErr()
 6    Sales->FirstName := cFirst
 7    Sales->LastName := cLast
 9    QOut("Append operation failed")
The following example first locks a record and then appends a blank record to the SALES database without releasing the record locks in the current lock list.
It also checks for errors:
1USE sales NEW
2DBRLock()        // Lock the current record
3// Add a new record but keep the old lock
4IF DBAppend(FALSE) .AND. !NetErr()
5    ? "Multiple records are locks"
7    ? "An error has occurred!"
See Also