4D v14REPLICATE |
||||||||||||||
|
4D v14
REPLICATE
REPLICATE
The REPLICATE command lets you replicate the data of a table of database A into that of a table of database B. By convention, the database where the command is executed is called the "local database" and the database from which the data are replicated is called the "remote database." This command can only be used in the framework of a database replication system. In order for the system to work, replication must have been enabled on the local database and the remote database side and each table implicated must have a primary key. For more information about this system, please refer to the Replication via SQL section. Note: If you would like to implement a complete synchronization system, please refer to the description of the SYNCHRONIZE command. Pass a list of fields (virtual or standard) separated by commas in replicated_list. The fields must belong to the table_reference table of the remote database. Note: The virtual fields of the remote table can only be stored in the arrays of the local database. The optional WHERE clause can be used to apply a preliminary filter to the records of the table in the remote database so that only those records that satisfy the search_condition will be taken into account by the command. 4D then recovers the values of the replicated_list fields for all the records designated by the FOR REMOTE STAMP clause. The value passed in this clause can be either:
Finally, you can apply the optional OFFSET and/or LIMIT clauses to the selection obtained:
Once both clauses have been applied, the resulting selection is sent to the local database. The values recovered are directly written into the target_list of the local database or in the standard fields specified by sql_name of the table_reference table of the local database. The target_list argument can contain either a list of standard fields or a list of arrays of the same type as the remote fields (but not a combination of both). If the destination of the command is a list of fields, the target records will be automatically created, modified or deleted according to the action stored in the virtual __ROW_ACTION field. You resolve conflicts for replicated records that already exist in the target database (identical primary keys) using priority clauses (REMOTE OVER LOCAL or LOCAL OVER REMOTE):
If the replication operation is carried out correctly, the OK system variable is set to 1. You can check this value from a 4D method. If errors occur during the replication operation, the operation is stopped at the first error that occurs. The last source variable (if it has been specified) is valorized with the stamp of the record in which the error occurred. The OK system variable is set to 0. The error generated can be intercepted by an error-handling method installed by the ON ERR CALL command. Note: Operations carried out by the REPLICATE command do not take data integrity constraints into account. This means, for instance, that the rules governing foreign keys, uniqueness, and so on, are not checked. If the data received could undermine data integrity, you must check the data after the replication operation is finished. The simplest way is to lock, via the 4D or SQL language, the records that have to be modified. |
PROPERTIES
Product: 4D SEE ALSO
Replication via SQL ARTICLE USAGE
4D SQL Reference ( 4D v14) |
||||||||||||