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 » Introducing MobiLink Synchronization » The synchronization process » MobiLink events

MobiLink events Next Page

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, in some cases you may need to edit them.

Following are the typical upload scripts for tables:

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 first event, upload_insert, triggers the running of the upload_insert script, which inserts the emp_id and emp_name into the emp table. In like fashion, the upload_delete and upload_update scripts will perform similar functions for delete and update actions on the same emp table.

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}

There should be no implicit or explicit commit or rollback in your SQL synchronization scripts or the procedures or triggers that are called from your SQL synchronization scripts. COMMIT or ROLLBACK statements within SQL scripts alter the transactional nature of the synchronization steps. If you use them, MobiLink cannot guarantee the integrity of your data in the event of a failure.

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.

For more information about programming synchronization logic, see Options for writing synchronization logic.

For information about RDBMS-dependent scripting, such as scripting for Oracle, Microsoft SQL Server, IBM DB2 UDB, or Adaptive Server Enterprise databases, 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:

See Adding and deleting scripts.