Add a new record to a database file.
XSharp.RT (in XSharp.RT.dll) Version: 2.3b
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.
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", ;
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
4IF DBAppend(FALSE) .AND. !NetErr()
5 ? "Multiple records are locks"
7 ? "An error has occurred!"