This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||
|
4D v20 R7
Replication via SQL
|
Virtual field | Type | Content | Use |
__ROW_ID | Int32 | ID of record | In any SQL statement except for REPLICATE or SYNCHRONIZE |
__ROW_STAMP | Int64 | Record replication information | In any SQL statement |
__ROW_ACTION | Int16 | Type of action carried out on the record: 1 = Addition or modification, 2 = Deletion | Only with the REPLICATE or SYNCHRONIZE command |
When the replication mechanisms are enabled, as soon as a record is created, modified or deleted, the corresponding information is automatically updated in the virtual fields of this record.
By default the mechanisms that allow replication are not enabled. You must explicitly enable them in both the remote and local database for each table to be used in the replication or synchronization.
Please note that enabling the mechanism does not trigger the replication itself; in order for the data to actually be replicated in a local or synchronized database, you must use the REPLICATE or SYNCHRONIZE commands.
To enable the internal replication mechanism, for each table (on the remote and local database) you must use the Enable Replication table property that is found in the table Inspector:
Note: In order for the replication mechanism to be able to function, you must specify a primary key for the tables implicated in the remote and local databases. You can create this key via the structure editor or using SQL commands. If no primary key has been specified, the option is grayed out.
When this option is checked, 4D generates the information necessary for replicating the records of the table (based more particularly on the primary key of the table). This information is stored in the virtual __ROW_STAMP and __ROW_ACTION fields.
Note: It is possible to enable and disable the generation of replication information via the SQL CREATE TABLE and ALTER TABLE commands, using the ENABLE REPLICATE and DISABLE REPLICATE keywords. For more information, please refer to the description of these commands.
WARNING: Checking this option causes information needed for replication mechanisms to be published. For security reasons, you must protect access to this information -- just as you protect access to your data when it is published. As a result, when you implement a replication system using this option, you must make sure that:
• if the SQL server is launched, access is protected using 4D passwords and/or SQL schemas (see Configuration of 4D SQL Server),
• if the HTTP server is launched, access is protected using 4D passwords and/or SQL schemas (see Configuration of 4D SQL Server) and/or the On Web Authentication Database Method and/or defining a virtual structure using the SET TABLE TITLES and SET FIELD TITLES commands. For more information, refer to the "URL 4DSYNC/" paragraph in the QR Get drop column section.
Once the replication mechanism is enabled in the each table of each database, you can use it from the local database via the SQL REPLICATE command. For more information, please refer to the description of this command.
Product: 4D
Theme: Using SQL in 4D
4D SQL Reference ( 4D v20 R7)