Tech Tip: How to Build the Table Definition for a Replication
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: October 5, 2010
The new SQL commands REPLICATE and SYNCHRONIZE in 4D v12 can be used to synchronize the data between different tables in different databases.
The documentation for these commands specifies the following syntax for the table definition:
table_reference (sql_name_1;...;sql_name_N) |
The implication being that the table definition should contain fields 1 through N. It is worth noting that not all fields are *required*. Here is an example:
Given the following table:
The complete table definition would be:
Groups ( Group_ID, Name, Description, Date_Created, Date_Modified ) |
However it is possible to only synchronize some of the fields so, for example, here is a valid SYNCHRONIZE statement for this table:
Begin SQL SYNCHRONIZE LOCAL TABLE Groups ( Group_ID, Name, Description ) WITH REMOTE TABLE Groups ( Group_ID, Name, Description ) FOR REMOTE STAMP :remoteStamp_l, LOCAL STAMP :localStamp_l LOCAL OVER REMOTE LATEST REMOTE :latestRemoteStamp_l, LATEST LOCAL :latestLocalStamp_l; End SQL |
In this case only the fields Group_ID, Name, and Description would be synchronized. On the other hand keep in mind that the fields to be synchronized must be enumerated; there is no "implicit" synchronization.