You want to copy new records only. In other words, you want to copy those records which exist in the local server but not in the remote server.
Method-1:
I assume you have a primary key for the table, or atleast a unique key.
In this case the above statement
- Code: Select all Expand view RUN
oRemote:Insert( cTable, nil, oLocal:Execute( "SELECT * FROM " + cTable ), .f. )
works. We read the entire table from the local server and send the entire table to the remote server. The remote server then checks if the primary/unique key already exists. If exists, it ignores and if not it inserts the new record.
Method-2:
The following code is similar but behaves a little diffently
- Code: Select all Expand view RUN
oRemote:Insert( cTable, nil, oLocal:Execute( "SELECT * FROM " + cTable ), .t. )
Here also we send the entire table to the remote server. If the primary/unique does not exist, it inserts the new record and if exists, if updates the existing record with the new data. In case any changes are made subsequently to the records already exported, these changes are also exported to the remote server.
Method-3:
Assume you have a primary key, which is an autoinc field. Also assume the name of the field to be ID.
It is possible to read and send only those records which are new. This saves lot of time and network traffic.
- Code: Select all Expand view RUN
nMaxId := oRemote:QueryResult( "select max(id) from " + cTable )
oRemote:Insert( cTable, nil, oLocal:Execute( "SELECT * FROM " + cTable + " WHERE id > ?", { nMaxId } ), .f. )
Method-4:
You do not have primary or unique key. (very bad programming practice)
Zap the table on the remote and export the full table again
You can now choose the method that suits your case.