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.10
Syntax
 FUNCTION DbAppend(
	 lReleaseLocks AS USUAL
) AS LOGIC
View Source

Parameters

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.

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.
Remarks
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.  For more information, refer to "Concurrency Control" in the Programmer's Guide.
Examples
The following example appends a blank record, checks for a NetErr() condition, and updates the data:
X#
DBUseArea(TRUE, "DBFNTX", "sales", "Sales", ;
                                TRUE)
... <Statements>
DBAppend()
IF !NetErr()
        Sales->FirstName := cFirst
        Sales->LastName := cLast
ELSE
        QOut("Append operation failed")
ENDIF
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:
X#
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"
ELSE
        ? "An error has occurred!"
ENDIF
See Also