Contents Index MobiLink events Stored procedures

MobiLink Synchronization User's Guide
  Synchronization Basics
    The synchronization process
      MobiLink events

MobiLink scripts

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

Following are some typical synchronization scripts for tables.

Event Script
upload_insert
INSERT INTO
emp (emp_id,emp_name)
VALUES (?,?)
upload_delete
DELETE FROM emp
WHERE emp_id=?
upload_update
UPDATE emp
SET emp_name=?
WHERE emp_id=?
upload_old_row_insert
INSERT INTO old_emp
(emp_id,emp_name)
VALUES (?,?)
upload_new_row_insert
INSERT INTO new_emp
(emp_id,emp_name)
VALUES (?,?)
upload_fetch
SELECT id, name, size, quantity, unit_price
FROM Product WHERE 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 tables 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 emp_id, emp_name
   FROM emp
   WHERE emp_name = ?

The download_cursor acquires data from the emp table for a specified emp_name.

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

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 synchronization server, to connect to a database, manipulate variables, and create user-defined procedures that can work with MobiLink and any supported relational database. There is a MobiLink Java API and a MobiLink .NET API that have routines to suit the needs of synchronization.

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

For information about DBMS-dependent scripting, such as scripting for Oracle, MS SQL Server, IBM DB2 or Adaptive Server Enterprise databases, see DBMS-dependent scripts.

Storing scripts 

SQL scripts are stored in system tables in the consolidated database. For Java and .NET, pointers to other locations are stored in the consolidated database. You can add all kinds of scripts to a consolidated database in two ways:

For more information, see Adding and deleting scripts in your consolidated database.


Contents Index MobiLink events Stored procedures