Click or drag to resize

DbTrans Function

Transfer records to an open database file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION DbTrans(
	 wTarget AS USUAL,
	 aStruct AS USUAL,
	 cbForCondition AS USUAL,
	 cbWhileCondition AS USUAL,
	 nNext AS USUAL,
	 nRecord AS USUAL,
	 lRest AS USUAL
) AS LOGIC
View Source

Parameters

wTarget
Type: Usual
The work area number of the destination file.
aStruct
Type: Usual
An array containing field descriptions in the format returned by DBStruct().  This array contains the structure of the source file.
cbForCondition
Type: Usual
A code block that defines a condition that each record within the scope must meet in order to be processed.
cbWhileCondition
Type: Usual
A code block that defines another condition that each record must meet in order to be processed.  As soon as a record is encountered that causes the condition to fail, the operation terminates.  If no scope is specified, having a <cbWhileCondition> changes the default scope to <lRest>.
You define the scope using one of these three, mutually exclusive arguments.  The default is all records.
nNext
Type: Usual
The number of records to append, starting at the current record.
nRecord
Type: Usual
The number of the record to append.
lRest
Type: Usual
TRUE processes only records from the current record to end-of-file.  FALSE processes all records.

Return Value

Type: Boolean
TRUE if successful; otherwise, FALSE.
Remarks
DBTrans() copies records from one work area to another open database file. By default, this function operates on the currently selected work area.  It can be made to operate on an unselected work area by specifying it within an aliased expression.
Tip Tip
Deleted source records: If SetDeleted() is FALSE, records are copied; however, the deleted records do not retain their deleted status.  No record is marked for deletion in the target file regardless of its status in the source file If SetDeleted() is TRUE, deleted records are not copied to the target database file.  Similarly, filtered records are ignored during a copy and are not included in the target file.
Examples
The following example appends the contents of file TESTFROM.DBF to TESTTO.DBF:
X#
USE testto
IF !Used()
        ? "Error opening TESTTO.DBF"
ELSE
        siTo := VODBGetSelect()
        USE testfrom NEW
        IF !Used()
                ? "Error opening TESTFROM.DBF"
        ELSE
                siFrom := VODBGetSelect()
                aStruct := DBStruct()
                DBTrans(siTo, aStruct)
                CLOSE
                DBSetSelect(siTo)
        ENDIF
        CLOSE
ENDIF
See Also