Click or drag to resize

DbUpdate Function

X#
Replace fields in the current work area with values from another work area, based on the specified key expression.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION DbUpdate(
	cAlias,
	cbKey,
	lRand,
	cbReplace
) AS LOGIC CLIPPER
Request Example View Source

Parameters

cAlias (Optional)
Type: Usual
The alias identifier for the source work area used to update records in the current work area.
If there is no open database file associated with the specified alias, a runtime error is raised.
cbKey (Optional)
Type: Usual
A code block defining the expression that defines matching records in the source work area.
lRand (Optional)
Type: Usual
Random access flag.
If TRUE, the current work area must be ordered (using an index order) by cbKey but the source work area records can be in any order.
If FALSE, both the current work area and the source work area must be ordered (logically or physically) by Eval(cbKey).
cbReplace (Optional)
Type: Usual
A code block defining how fields in the current work area should be replaced.

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks
For a shared database, DBUpdate() requires a file lock on the current database file.
The source database file can be open in any mode. DBUpdate() is the functional equivalent of the UPDATE command.
Tip Tip
Deleted records: If SetDeleted() is FALSE, deleted records in both source files are processed. Records in the file being updated retain their deleted status and are not affected by the deleted status of records in the source file.
If SetDeleted()is TRUE, however, no deleted records are processed from either source file
Examples
The following example updates the current work area from the TEST2 database (note the condition imposed by the bReplace evaluation):
X#
1DBUpdate("test2", {||Last},, ;
2                {||_FIELD->Salary := 0.00})
See Also