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: Using MobiLink with a SQL Anywhere consolidated database

 

Lesson 3: Creating a synchronization model

In this lesson, you use the Create Project Wizard to create a new MobiLink project. The Create Project Wizard also creates a synchronization model using the defaults, which can be edited later.

Prerequisites

This lesson assumes you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Using MobiLink with a SQL Anywhere consolidated database.

This lesson assumes you have completed all preceding lessons. See Lesson 1: Designing the schemas.

 Task
  1. In Sybase Central, click Tools » MobiLink 16 » New Project.

  2. The Create Project Wizard appears.

  3. In the What do you want to name the new project field, type mlsqla_project.

  4. In the Where do you want to save the new project field, type C:\mlsqla, and click Next.

  5. In the Database display name field, type demo.

  6. Click Edit.

  7. Perform the following tasks in the Connect To A Generic ODBC Database page:

    1. In the ODBC Data Source name field, click Browse and choose SQL Anywhere 16 Demo.

    2. Click OK, and click Save.

  8. Select the Remember the password option, and click Next.

  9. On the New Remote Database Schema page, in the Which consolidated database tables and columns do you want to have in your remote database list, select the following tables:

    • CustomerProducts
    • Customers
    • Products
    • SalesOrders

    Click Next.

  10. Select the Add a remote schema name to the project option.

  11. In the What do you want to name the new remote schema field, type mlsqla_remote_schema and click Next.

  12. Choose UltraLite for the Which type of remote database do you want to use option and click Finish.

  13. Click Yes when you are prompted to install the MobiLink setup scripts.

  14. Click Yes if you are prompted to import the remote schema.

  15. Click OK.

  16. Right-click the new synchronization model and choose Properties.

    1. Type sync_mlsqla in the first field.

    2. Type sync_mlsqla_publication in the Publication name field.

    3. Type sync_mlsqla_scriptversion in the Script version field.

      The publication is the object on the remote database that specifies what data is synchronized. MobiLink server scripts define how uploaded data from remotes should be applied to the consolidated database, and how script versions group scripts. You can use different script versions for different applications, allowing you to maintain a single MobiLink server while synchronizing different applications.

    4. Click Apply and then click OK.

  17. Perform the following tasks in the right pane of Sybase Central:

    1. Click the Events tab.

    2. Update the CustomerProducts download cursor to only download customer products for customers in the Eastern region.

      Replace the existing SQL script for the download_cursor event for the CustomerProducts table with the following query:

      SELECT "DBA"."CustomerProducts"."ID",
          "DBA"."CustomerProducts"."SalesOrderID", 
          "DBA"."CustomerProducts"."CustomerID", 
          "DBA"."CustomerProducts"."ProductID" 
      FROM "DBA"."CustomerProducts" 
      INNER JOIN "GROUPO"."Customers" ON "GROUPO"."Customers"."ID" = 
          "DBA"."CustomerProducts"."CustomerID"
      WHERE "GROUPO"."Customers"."Region" = 'Eastern';
    3. Update the download cursor for the Customers table to only download customer information from the Eastern Region.

      Replace the existing SQL script for the download_cursor event for the Customers table with the following query:



      SELECT "GROUPO"."Customers"."ID",
          "GROUPO"."Customers"."Surname",
          "GROUPO"."Customers"."GivenName",
          "GROUPO"."Customers"."Street",
          "GROUPO"."Customers"."City",
          "GROUPO"."Customers"."State",
          "GROUPO"."Customers"."Country",
          "GROUPO"."Customers"."PostalCode",
          "GROUPO"."Customers"."Phone",
          "GROUPO"."Customers"."CompanyName",
          "GROUPO"."Customers"."Region"
      FROM "GROUPO"."Customers"
      WHERE Region = 'Eastern';
    4. Update the SalesOrders download cursor to only download sales order information for customers in the Eastern region.

      Replace the existing SQL script for the download_cursor event for the SalesOrders table with the following query:



      SELECT "GROUPO"."SalesOrders"."ID",
           "GROUPO"."SalesOrders"."CustomerID",
           "GROUPO"."SalesOrders"."OrderDate",
           "GROUPO"."SalesOrders"."FinancialCode",
           "GROUPO"."SalesOrders"."Region",
           "GROUPO"."SalesOrders"."SalesRepresentative"
      FROM "GROUPO"."SalesOrders"
      WHERE "GROUPO"."SalesOrders"."Region" = 'Eastern' 
      AND "GROUPO"."SalesOrders"."ID" IN 
      (SELECT "DBA"."CustomerProducts"."SalesOrderID" 
      FROM "DBA"."CustomerProducts");
  18. Save the synchronization model.

    Click File » Save.

    The synchronization model is complete and ready for deployment.

Results

A MobiLink project and synchronization model are created.

 See also