Contents Index Synchronizing customers in the Contact sample Synchronizing products in the Contact sample

MobiLink Synchronization User's Guide
  The Contact Sample Application
    Synchronization

Synchronizing contacts in the Contact sample


The Contact table contains the name of a person working at a customer company, a foreign key to the customer and a unique integer identifying the contact. It also contains a last_modified timestamp and a marker to indicate whether the contact is active.

Business rules 

The business rules for this table are as follows:

Trigger 

A trigger on the Customer table is used to ensure that the contacts get picked up when information about a customer is changed. The trigger explicitly alters the last_modified column of each contact whenever the corresponding customer is altered:

CREATE TRIGGER UpdateCustomerForContact
AFTER UPDATE OF rep_id ORDER 1
ON DBA.Customer
REFERENCING OLD AS old_cust NEW as new_cust
FOR EACH ROW
BEGIN
  UPDATE Contact
  SET Contact.last_modified = new_cust.last_modified
  FROM Contact
  WHERE Contact.cust_id = new_cust.cust_id
END

By updating all contact records whenever a customer is modified, the trigger ties the customer and their associated contacts together so that whenever a customer is modified, all associated contacts are modified too, and will be downloaded together on the next synchronization.

Downloads 
Uploads 

Contact information can be inserted, updated, or deleted at the remote database. The scripts corresponding to these operations are as follows:


Contents Index Synchronizing customers in the Contact sample Synchronizing products in the Contact sample