SymmetricDS:应该使用哪种方法来同步特定表? [英] SymmetricDS: Which approach should I use to synchronize specific tables?

查看:239
本文介绍了SymmetricDS:应该使用哪种方法来同步特定表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试SymmetricDS,并且对于应该使用哪种方法来同步某些特定表有些疑问.我有两个应用程序,第一个是ERP,第二个是PDV.某些表可以同步到所有PDV数据库,但是,在某些表中,该行应同步到特定的PDV实例:

I'm testing SymmetricDS and I'm having some doubt about which approach I should use to synchronize some specific tables. I have two application, the first is a ERP and the second is a PDV. Some tables can be synchronized to all PDV databases, however, in some tables the row should synchronize to a specific PDV instance:

在此图中,红色矩形显示需要同步的表,绿色箭头显示可以识别要同步哪个SymmetricDS实例的列.我的问题是:应该使用哪种方法(bsh,subselect,lookuptable等)以及如何做到这一点?

In this diagram, the red rectangles show which table need synchronize, and the green arrow show the column where we can identify which SymmetricDS instance will synchronize. My question is: which approach I should use to do this (bsh, subselect, lookuptable, etc) and how I do it?

推荐答案

您需要一个子选择路由器(实际上需要三个).我只向您显示Funcionario的SQL,然后您将可以自己找出CadastroFuncionario_funcao的配置:

You need a subselect router (actually you need three). I only show you the SQL for Funcionario, then you'll be able to figure out the configuration for Cadastro and Funcionario_funcao by yourself:

insert into SYM_ROUTER 
  (router_id, source_node_group_id, target_node_group_id, router_type, 
    router_expression, create_time, last_update_time)
values
  ('erp_to_pdv__funcionario', 'erp', 'pdv', 'subselect', 
    'c.external_id in (
        select empresa.CNPJ
          from cadastro join empresa
            on cadastro.id_empresa = empresa.id_empresa
          where cadastro.CPFCGC=:ID_CADASTRO
     )', 
    current_timestamp, current_timestamp);

当路由Funcionario表中的记录时,此路由器会选择所有external_id等于链接到给定FuncionarioEmpresa.CNPJ的节点(我假定Funcionario.id_cadastro是对Cadastro.CPFCGC)

When a record from the Funcionario table is routed, this router picks all the nodes with external_id equal to the Empresa.CNPJ linked to the given Funcionario (I assumed Funcionario.id_cadastro to be the reference to Cadastro.CPFCGC)

请注意,我使用的是c.external_id,但是您可能要使用c.node_id(取决于您放入Empresa.CNPJ的内容).

Note I used c.external_id, but you may want to use c.node_id (depends on what you put into Empresa.CNPJ).

这篇关于SymmetricDS:应该使用哪种方法来同步特定表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆