Synchronizing customers in the CustDB sample

Business rules

The business rules governing customers are as follows:

  • Customer information can be modified at both the consolidated and remote databases.

  • Both the remote and consolidated databases contain a complete listing of customers.

Downloads

Customer information can be inserted or updated at the consolidated database. The script corresponding to these operations is as follows:

  • download_cursor   The following download_cursor script downloads all customers for whom information has changed since the last time the user downloaded information.
    SELECT cust_id, cust_name FROM ULCustomer WHERE last_modified >= {ml s.last_table_download}

Uploads

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

  • upload_insert   The upload_insert script for CustDB is as follows:
    INSERT INTO ULCustomer( cust_id, cust_name )
       VALUES( {ml r.cust_id, r.cust_name } )

  • upload_update   The upload_update script for CustDB is as follows:
    UPDATE ULCustomer SET cust_name = {ml r.cust_name} 
       WHERE cust_id = {ml r.cust_id}

    Conflict detection is not performed on this table.

  • upload_delete   The upload_delete script for CustDB is as follows:
    DELETE FROM ULCustomer WHERE cust_id = {ml r.cust_id}