Add a new record to a database file.
XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax View Source
lReleaseLocks AS USUAL
) AS LOGIC
public static bool DbAppend(
[DefaultParameterValueAttribute(0, 1)] Usual lReleaseLocks
- 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.
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.
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. For more information, refer to "Concurrency Control" in the Programmer's Guide.
The following example appends a blank record, checks for a NetErr() condition, and updates the data:
DBUseArea(TRUE, "DBFNTX", "sales", "Sales", ;
Sales->FirstName := cFirst
Sales->LastName := cLast
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:
USE sales NEW
DBRLock() // Lock the current record
// Add a new record but keep the old lock
IF DBAppend(FALSE) .AND. !NetErr()
? "Multiple records are locks"
? "An error has occurred!"