[Home] [Table of Contents] [Previous Section] [Next Section]
Breck Carter
Last modified: October 21, 1999
mail to: bcarter@bcarter.com


Tip 90: UltraLite Lite


7 - Write the Synchronization Scripts

Fancy synchronization scripts are what UltraLite and MobiLink are all about. But not for this article... we're just sending a single column in a single row in a single table back and forth between the consolidated and embedded databases. We don't need no steenking synchronization scripts, except for the defaults.

The two scripts we need are the upload_cursor script associated with the ULLDemo1 table, and the download_cursor script for the same table. When a HotSync operation is performed, these scripts are executed in that order: upload from Palm to server first, then download.

The upload_cursor script is stored on the consolidated database, and it is executed on that database whenever the HotSync conduit is executed. It specifies where to put the data (even though it says SELECT), and what the primary key is.

The UltraLite database software on the Palm takes care of building the actual upload stream, and this upload_cursor script simply describes what the rows look like and where to put them:

SELECT id, hello FROM ULLDemo1 WHERE id = ?

The download_cursor script is also stored on the consolidated database, and it is executed on that database whenever the HotSync conduit is executed. This script tells the conduit how to build the actual download stream: which rows and columns are to be downloaded. In this case it is all rows and all columns:

SELECT id, hello FROM ULLDemo1

These scripts are stored in a catalog table named dbo.ul_script which is linked to related tables in a simple schema:

UltraLite Script Catalog Tables

Like other catalog tables, ul_script cannot be updated directly.

Unlike like other catalog tables, however, there is no dbisql command like CREATE SCRIPT. You have to use Sybase Central Java Edition which ships with SQL Anywhere Studio:

Create the Upload and Download scripts in Sybase Central

And here's the joke: The two scripts called default_download_cursor and default_upload_cursor aren't defaults at all! They are templates, and even if they are exactly what you want (they are, for this article), you still have to use copy and paste.

Here's how to use Sybase Central to create the scripts:

  1. Use Start - Programs
    - Sybase
    - Adaptive Server Anywhere 6.0
    - Manage MobiLink Synchronization.

  2. Pick Tools - Connect,
    fill in the User ID, Password and Data Source fields,
    and press OK.

    Tools - Connect to MobiLink Synhronization

  3. Under MobiLink Synchronization,
    expand ulldemo1 and Synchronized Tables,
    and select ULLDemo1.

    Sybase Central - Synchronized Tables - ULLDemo1

  4. Doubleclick on default_download_cursor,
    copy the contents to the clipboard,
    and close that window.

    Event default_download_cursor of ULLDemo1

  5. Doubleclick on Add Table Script,
    pick download_cursor,
    paste the script from the clipboard
    and press Finish.

    Add Synchronizing Table Script Wizard

  6. Use the same technique to copy the default_upload_cursor script
    and create a new upload_cursor script.

Hey! Guess what! You don't have to copy and paste from the default scripts. You just have to doubleclick on Add Table Script, and pick upload_cursor or download_cursor, and the wizard fills in the default script for you!

That's way cool! Maybe it isn't a joke after all, maybe they really are "defaults".


[Home] [Table of Contents] [Previous Section] [Next Section] [mail to: bcarter@bcarter.com]