0

on my source table i have a boolean column and if the boolean is switched on SymmetricDS should insert a row into my target table. If it was switched off it should the (eventually) inserted row from target table.

After reading the Documentation these operation change was not possible. Any hint how can i build a workaround with the existing capabilities?

my current setup (for an update at source it can only insert at target, not delete from FP_HIST)

insert into sym_trigger (TRIGGER_ID, SOURCE_SCHEMA_NAME, SOURCE_TABLE_NAME, CHANNEL_ID, CREATE_TIME, LAST_UPDATE_TIME
, SYNC_ON_INSERT, SYNC_ON_DELETE, SYNC_ON_UPDATE, SYNC_ON_UPDATE_CONDITION) 
VALUES ('eventattendee2fphist', 'webapps_base', 'eventattendee', 'channel_fphist', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
, 0, 0, 1, 'new.attended AND new.id IN (select eat.id from webapps_base.eventattendee eat JOIN webapps_base.iacontact iac ON eat.fk_person_id = iac.fk_naturalperson_id AND NOT iac.lateregistration AND iac.access_path != ''FP_LATE_REGISTRATION'' JOIN webapps_base.event e ON e.id = eat.fk_event_id JOIN webapps_base.eventtypecatalog et ON et.id = e.fk_eventtypecatalog_id AND et.type = ''FP'' JOIN webapps_base.eventagencyassociations eag ON e.id = eag.fk_event_id JOIN webapps_base.agency ag ON ag.id = eag.fk_agency_id WHERE eat.attended)');

insert into SYM_TRIGGER_ROUTER (trigger_id, router_id, initial_load_order, create_time, LAST_UPDATE_TIME, ENABLED) 
values ('eventattendee2fphist', 'pg2ib', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 1);

insert into SYM_TRANSFORM_TABLE (
  transform_id, source_node_group_id, target_node_group_id, transform_point, SOURCE_SCHEMA_NAME, source_table_name,
  target_table_name, delete_action, transform_order, column_policy, update_first) 
values ('eventattendee2fphist', 'postgres', 'interbase', 'EXTRACT', 'webapps_base', 'eventattendee',
'FP_HIST', 'DEL_ROW', 1, 'SPECIFIED', 0);

insert into SYM_TRANSFORM_COLUMN (
  transform_id, include_on, target_column_name, source_column_name, pk,
  transform_type, transform_expression, transform_order) 
values ('eventattendee2fphist', '*', 'PVP', 'fk_Person_ID', 1, 'lookup', 'select ident FROM webapps_base.salespartner where fk_person_id = CAST(:fk_Person_ID AS BIGINT)', 1);


insert into SYM_TRANSFORM_COLUMN (
  transform_id, include_on, target_column_name, source_column_name, pk,
  transform_type, transform_expression, transform_order) 
values
('eventattendee2fphist', '*', 'VP',  'id',           0, 'lookup', 'select br.ident from webapps_base.eventattendee eat JOIN webapps_base.iacontact iac ON eat.fk_person_id = iac.fk_naturalperson_id AND NOT iac.lateregistration AND iac.access_path != ''FP_LATE_REGISTRATION'' JOIN webapps_base.salespartner br ON br.id = eat.fk_bringersalespartner_id WHERE eat.id = CAST(:id AS BIGINT)', 2);

insert into SYM_TRANSFORM_COLUMN (
  transform_id, include_on, target_column_name, source_column_name, pk,
  transform_type, transform_expression, transform_order) 
values ('eventattendee2fphist', '*', 'STADT_NR', 'fk_Person_ID', 0, 'lookup', 'select ag.agencynumber FROM webapps_base.salespartner sp join webapps_base.salespartneragencystructure sag on sp.id = sag.fk_salespartner_member join webapps_base.agency ag on ag.id = sag.fk_agency_id where sp.fk_person_id = CAST(:fk_person_id AS BIGINT)', 3);

insert into SYM_TRANSFORM_COLUMN (
  transform_id, include_on, target_column_name, source_column_name, pk,
  transform_type, transform_expression, transform_order) 
values ('eventattendee2fphist', '*', 'DATUM', 'id', 0, 'lookup', 'select e.eventdate FROM webapps_base.eventattendee eat JOIN webapps_base.event e ON e.id = eat.fk_event_id WHERE eat.id = CAST(:id AS BIGINT)', 4);
Markus Schulz
  • 500
  • 5
  • 12
  • Let me try understanding your question. There's a table A both on source and target node. There's a column b on the table A of boolean type. If there's an insert at the source of a row in the table A with b==true you want the row to get inserted in the target node as well. – Boris Pavlović Aug 06 '15 at 07:02
  • I don't understand what kind of behavior is required when b==false. Do you want to skip the synchronization of newly inserted row? – Boris Pavlović Aug 06 '15 at 07:03
  • no, the table A is not available on target. i have a table "event_attendees" on source with a boolean column "attended". The insert case is not important, only "updates" on source. If the attended was set to true i want to create a "protocoll-entry" on target and if switched back to false i want to delete these possibly created "protocoll-entry". – Markus Schulz Aug 06 '15 at 07:17
  • Is there a transformation from source table A to target table M? Is there a routing defined? – Boris Pavlović Aug 06 '15 at 07:20
  • I would suggest to create a table "protocol-entry" at the source with a column that will identify target node identity and let the application code at the source insert/delete "protocol-entry" rows. Then use routing to sync "protocol-entry" insertions/deletions to respecrive target nodes using column base routing. Does it make sense? – Boris Pavlović Aug 06 '15 at 07:26
  • i've implemented this as a new feature for symmetricDS. You can setup an "update_action" like the existing "delete_action" but with support for bsh-scripts where you can return "INS_COL", "UPD_COL", "DEL_COL" from you bsh script. You can access the column values inside the script. – Markus Schulz Aug 10 '15 at 10:59
  • See http://www.symmetricds.org/issues/view.php?id=2367 for my patch. – Markus Schulz Aug 10 '15 at 11:11

1 Answers1

0

it's possible now with my own enhancement to symmetricDS and my branch at github

Markus Schulz
  • 500
  • 5
  • 12