table.RECORD_CLONE Function
Syntax
Arguments
- source_table
A pointer to the table to be cloned.
Description
Create a new record using the fields from a similar table.
Discussion
The <TBL>.RECORD_CLONE() method copies all the field values from the current record of the source table, and places them in the record buffer for the current record in the destination table. The source table is referenced by the <Source_Table> object pointer, and the destination table is referenced by the <Destination_Table> object pointer. The source and destination tables must have the same structure. <Source_Table> cannot reference a set. If you want to copy data from the current record in a set, open a second instance of the appropriate table in the set and position the record pointer in this new instance of the table. The <TBL>.RECORD_CLONE() method must occur between corresponding <TBL>.ENTER_BEGIN() and <TBL>.ENTER_END() or <TBL>.CHANGE_BEGIN() and <TBL>.CHANGE_END() methods.
Example
This script adds all the records from the source table to the destination table.
tbl_source = table.open("names1", FILE_RW_EXCLUSIVE) tbl_dest = table.open("names2", FILE_RW_EXCLUSIVE) tbl_source.fetch_first() while .NOT. tbl_source.fetch_EOF() tbl_dest.enter_begin() tbl_dest.record_clone(tbl_source) tbl_dest.enter_end(.T.) tbl_source.fetch_next() end while tbl_source.close() tbl_dest.close()
See Also