Source Database: Change-log and State Tables

PDS accesses a change-log table and a state table in the database.  Your application must create these in the source database.

Change-log Table

The change-log table can have any table name that is valid in the source database. This name is entered in the PDS configuration file.

Your application must populate changes into the change-log table.  PDS periodically checks this table for changes, which need to be synced.  Changes are synchronized according to the change-id order.

Each change-log table must be used by only a single PDS command. Using a change-log table in multiple PDS commands will lead to synchronization errors.

The change-log table must have the following structure:

Column name

Data Type

Description

change_id

  • 64-bit integer

  • Primary Key

  • Orders the changes.

  • Non-negative.

record_key

VARCHAR

Record key

parent_key

VARCHAR

Key of parent record, the parent key can be omitted for non-child tables.

Deletion

BIT

Indicates of the record change is an add/update (0), or a deletion (1).

1 – deletion, 0 – add/update

column name

VARCHAR

The name of a column in the RDBMS table.

Repeatable, one per RDBMS table column.

If the change-log table has additional columns, PDS ignores them. A timestamp column is a common addition.

State Table

The state table can have any table name valid in the source database. This name is entered into the PDS configuration file.

Your application does not need to populate the state table. PDS will update it.

The state table must have the following structure:

Column name

Data Type

Description

table_name

VARCHAR

Primary Key

Name of the RDBMS table

change_id

64-bit integer

The highest change-id that has been synchronized.

Your application can obtain PDS’ synchronization state can be obtained by reading the state table.

If the state table has additional columns, PDS ignores them. However, such columns must have a default value, or PDS can encounter an error updating the state table. A timestamp column is a common addition.

A single state table can be used by multiple PDS commands.

Erasing a row in the state table or setting the change_id value to 0 causes PDS to re-synchronize all changes for the table named in that row.