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.7
	wTarget AS USUAL := NIL,
	aStruct AS USUAL := NIL,
	cbForCondition AS USUAL := NIL,
	cbWhileCondition AS USUAL := NIL,
	nNext AS USUAL := NIL,
	nRecord AS USUAL := NIL,
	lRest AS USUAL := NIL
Request Example View Source


wTarget (Optional)
Type: Usual
The work area number of the destination file.
aStruct (Optional)
Type: Usual
An array containing field descriptions in the format returned by DBStruct().
This array contains the structure of the source file.
cbForCondition (Optional)
Type: Usual
A code block that defines a condition that each record within the scope must meet in order to be processed.
cbWhileCondition (Optional)
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, <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 (Optional)
Type: Usual
The number of records to append, starting at the current record.
nRecord (Optional)
Type: Usual
The number of the record to append.
lRest (Optional)
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.
Tip Tip
The <nNext>, <nRecord>, and <lRest> arguments are mutually exclusive. You should not pass all three of them. And if you pass the <cbWhile> argument then this also controls the scope behavior.
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.
The following example appends the contents of file TESTFROM.DBF to TESTTO.DBF:
 1USE testto
 2IF !Used()
 3    ? "Error opening TESTTO.DBF"
 5    siTo := VODBGetSelect()
 6    USE testfrom NEW
 7    IF !Used()
 8        ? "Error opening TESTFROM.DBF"
 9    ELSE
10        siFrom := VODBGetSelect()
11        aStruct := DBStruct()
12        DBTrans(siTo, aStruct)
13        CLOSE
14        DBSetSelect(siTo)
15    ENDIF
16    CLOSE
See Also