Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » MobiLink - Getting Started » Exploring the CustDB Sample for MobiLink » Synchronizing CustDB

Synchronization logic source code Next Page

Synchronizing orders in the CustDB sample


Business rules

The business rules for the ULOrder table are as follows:

Downloads

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

SELECT o.order_id, o.cust_id, o.prod_id, o.emp_id, o.disc, o.quant, o.notes, o.status
    FROM ULOrder o, dba.ULEmpCust ec
  WHERE o.cust_id = ec.cust_id 
    AND ( ( o.status = ''Approved'' AND o.last_modified >= {ml s.last_table_download} ) 
    OR ( ec.action = ''D''  )  )
    AND ec.emp_id = {ml s.username}
Uploads

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

INSERT INTO ULOrder ( order_id, cust_id, prod_id, emp_id, disc, quant, notes, status )
   VALUES( {ml r.order_id, r.cust_id, r.prod_id, r.emp_id, r.disc, r.quant, r.notes, r.status } )
UPDATE ULOrder 
  SET cust_id = {ml r.cust_id},
      prod_id = {ml r.prod_id},
      emp_id = {ml r.emp_id},
      disc = {ml r.disc},
      quant = {ml r.quant},
      notes = {ml r.notes},
      status = {ml r.status}
    WHERE order_id = {ml r.order_id}
DELETE FROM ULOrder WHERE order_id = {ml r.order_id}
SELECT order_id, cust_id, prod_id, emp_id, disc, quant, notes, status
   FROM ULOrder WHERE order_id = {ml r.order_id}
INSERT INTO ULOldOrder ( order_id, cust_id, prod_id, emp_id, disc, quant, notes, status )
   VALUES( {ml r.order_id, r.cust_id, r.prod_id, r.emp_id, r.disc, r.quant, r.notes, r.status } )
INSERT INTO ULNewOrder ( order_id, cust_id, prod_id, emp_id, disc, quant, notes, status )
   VALUES( {ml r.order_id, r.cust_id, r.prod_id, r.emp_id, r.disc, r.quant, r.notes, r.status } )
Conflict resolution