Search code examples
routersymmetricds

SymmetricDS: How to configure router to sync header detail relationship


I have 2 tables

HeaderTable: 
Header_ID Header_Status

DetailTable:
Detail_ID Header_ID 

I want to sync HeaderTable based on Header_Status = A, this can be done by setting column router Header_Status=A

For DetailTable, I want to do a checking to sync only if the Header_ID has already sync to the target, which means I have to route based on query like select * from HeaderTable where Header_ID=:Header_ID

How could I achieve this in the sym_router?


Solution

  • Try the subselect router which allows for custom queries definition:

    select node_id
    from   sym_node
    where  0 < (
      select count(*)
      from   HeaderTable
      where  Header_ID=:Header_ID
      and    Header_Status = A);