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

SQL Anywhere 11.0.0 » MobiLink - Getting Started » Using MobiLink Technology » Introducing MobiLink synchronization » The synchronization process

 

MobiLink events

When the MobiLink client initiates a synchronization, a number of synchronization events occur. At the occurrence of a synchronization event, MobiLink looks for a script to match the event. The script contains instructions detailing what you want done. If you have defined a script for the event and put it in a MobiLink system table, it is invoked.

MobiLink scripts

Whenever an event occurs, the MobiLink server executes the associated script if you have created one. If no script exists, the next event in the sequence occurs.

Note

When you use the Create Synchronization Model Wizard to create your MobiLink application, all the required MobiLink scripts are created for you. However, you can customize the default scripts, including creating new scripts.

Following are the typical upload scripts for tables. The first event, upload_insert, triggers the running of the upload_insert script, which inserts any changes in the emp_id and emp_name columns into the emp table. The upload_delete and upload_update scripts perform similar functions for delete and update actions on the emp table.

Event Example script contents
upload_insert
INSERT INTO
emp (emp_id,emp_name)
VALUES {ml r.emp_id}, {ml r.emp_name}
upload_delete
DELETE FROM emp
WHERE emp_id = {ml r.emp_id}
upload_update
UPDATE emp
SET emp_name = {ml r.emp_name}
WHERE emp_id = {ml r.emp_id}

The download script uses a cursor. Following is an example of a download_cursor script:

SELECT order_id, cust_id
FROM ULOrder 
WHERE last_modified >= {ml s.last_table_download}
AND emp_name = {ml r.emp_id}

For more information about events and scripts, see:

Scripts can be written in SQL, Java, or .NET

You can write scripts using the native SQL dialect of your consolidated database, or using Java or .NET synchronization logic. Java and .NET synchronization logic allow you to write code, invoked by the MobiLink server, to connect to a database, manipulate variables, directly manipulate uploaded row operations, or add row operations to the download. There is a MobiLink server API for Java and a MobiLink server API for .NET that provide classes and methods to suit the needs of synchronization.

See Options for writing server-side synchronization logic.

For information about RDBMS-dependent scripting, see MobiLink consolidated databases.

Storing scripts

SQL scripts are stored in MobiLink system tables in the consolidated database. For scripts written with the MobiLink server APIs, you store the fully qualified method name as the script. You can add scripts to a consolidated database in several ways:

  • When you use the Create Synchronization Model Wizard, scripts are stored in the MobiLink system tables when you deploy your project.
  • You can manually add scripts to the system tables by using stored procedures that are installed when you set up a consolidated database.
  • You can manually add scripts to the system tables using Sybase Central.

See Adding and deleting scripts.