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

SAP Sybase SQL Anywhere 16.0 » MobiLink - Getting Started » MobiLink tutorials » Tutorial: Introducing MobiLink


Lesson 5: Refining a synchronization model

This lesson shows you how to make changes to your synchronization model and explores some of the choices available to you when developing a model.


This lesson assumes you have completed all preceding lessons. See Lesson 1: Setting up a MobiLink consolidated database.

This lesson assumes that you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Introducing MobiLink.

  1. In the left pane of Sybase Central under MobiLink 16, expand mlintro_project » Synchronization Models » sync_mlintro.

  2. In the Mappings tab, select the row for the Product table.

  3. In the lower pane, select the Conflict Handling tab.

  4. For Conflict Resolution, select Consolidated. Selecting this option means that if a row is modified on both the consolidated and remote databases, the value in the consolidated database is considered to be the correct one.

  5. In the Deployment tab, click Test. If you are prompted to save your synchronization model, click Yes.

  6. Select the Data tab and then click Synchronize to update the remote database.

  7. Edit the row named Screwmaster Drill and set the quantity on the consolidated database to 20 and the quantity on the remote database to 10.

  8. Click Synchronize. Both the remote and consolidated databases should show a quantity of 20.

  9. Close the Test window.

  10. Select the Events tab for the sync_mlintro model. This page shows the SQL statements that the MobiLink server runs for this synchronization model. The green bars in the left margin indicate that the SQL statements are automatically generated based on the choices you made in the Mappings tab.

    There may be times when the options available in the Mappings tab are not sufficient for your scenario. In these cases, you can further customize your synchronization scripts using the Events tab.

  11. In the Events tab, look for the upload_insert event for the Product table. This shows the SQL statements that the MobiLink server executes when it receives a new row from a remote database. We'll make a change to this event to limit any new orders to a maximum quantity of 50. The text {ml r."quantity"} represents the remote quantity column that was uploaded. Change this to the following:

    If {ml r."quantity"} < 50 then {ml r."quantity"} else 50 end if

    The full upload_insert event should now be as follows:

    Product (DBA): upload_insert
    /* Insert the row into the consolidated database. */
    INSERT INTO "DBA"."Product" ( "name", "quantity" )
    VALUES ( {ml r."name"}, If {ml r."quantity"} < 50 then {ml r."quantity"} else 50 end if )

    Notice that the bar in the margin is now yellow for the upload_insert event, indicating that the settings from the Mappings tab have been overridden.

  12. From the Deployment tab, click Test. Select the Data tab, and then click Synchronize. Now right-click in the lower pane for the remote database. Select Add Row then add a row with a name of Hammer and a quantity of 200. Click Synchronize. Now both the consolidated and remote database contain a value of 50 for the Hammer row.

  13. Close the Test window and return the Events tab. Right-click the upload_insert event script and then select Restore 'Product (DBA): upload_insert' Script. The bar in the margin is now green again, and the customizations made previously have been undone.


Changes are made to the synchronization model.

 See also