Working with scripts and users in Sybase Central

You can view and modify existing scripts and write new ones in the MobiLink Synchronization plug-in in Sybase Central. These procedures describe how to connect to the plug-in and write scripts, and how to add a user to the consolidated database.

StepsTo connect to a consolidated database in Sybase Central:

  1. Start Sybase Central and select Connections>Connect with MobiLink 11 from the menu bar.

  2. On the Identification page in the Connect to Consolidated Database dialog box, select or browse to a data source name or file, and click OK.

When you expand the node for a consolidated database in the MobiLink Synchronization plug-in, you see folders with the following labels: Tables, Connection Scripts, Synchronized Tables, Users, Versions, and Notifications. All the procedures in this section begin by opening one of these folders.

Script versions

Scripts are organized into groups called script versions. By specifying a particular version, MobiLink clients can select which set of synchronization scripts is used to process the upload stream and prepare the download stream. If you want to define different versions for scripts, you must add a script version to the consolidated database before you add scripts for it.

If you create two different versions, make sure that you have scripts for all required events in both versions.

StepsTo add a script version:

  1. Open the Versions folder, then select File>New>Version from the Sybase Central menu bar.

  2. In the Create Script Version wizard, provide a name for the version and optionally a description, then click Finish.

    Sybase Central creates the new version and gives it a unique integer identifier.

Adding synchronized tables and scripts

Scripts added for connection events are executed for every synchronization. Scripts added for table events are executed when a specific table has been modified. You must specify that a table is synchronized before you can add scripts for it.

StepsTo add a table for synchronization:

  1. Open the Synchronized Tables folder and select File>New>Synchronized Table.

  2. Specify a remote table name you want to synchronize or select a table in the consolidated database that has the same name as a table in the remote database.

  3. Click Finish.

StepsTo add a script to a synchronized table:

  1. Double-click a table name in the Synchronized Tables folder, then select File>New>Table Script.

  2. In the Create Table Script wizard, select the version for which you want to add a script, select the event you want to cause the script to execute, and click Next.

  3. Choose to create a new script definition and the language (SQL, Java, or .NET) in which you want to write the definition, or select an existing script version that you want to share for the new script.

  4. Click Finish.

  5. Type your script in the editor that displays, then save and close the file.

    For example, if you want to remove rows that have been shipped from the Order table in a remote database, you can place the following SELECT statement in the download_delete_cursor event, where order_id is the primary key column. The first parameter to this event is the last_download timestamp. It is used here to supply the value for a last_modified column:

    SELECT order_id
      FROM Order
    WHERE status = 'Shipped'
      AND last_modified >= ?
    

    For more information about using the download_delete_cursor event, see the section on “Writing download_delete_cursor scripts” in the online MobiLink - Server Administration book.

StepsTo add a connection-level script:

  1. Open the Connection Scripts folder and select File>New>Connection Script from the menu bar.

  2. Follow steps 2 to 5 in the previous procedure.

Adding users

You can add users directly to the ml_user table in the consolidated database, then provide the user names and optional passwords to your users. To add a user, open the Users folder, select File>New>User, and complete the Create User wizard.

You also have to add at least one user name to each remote database, as described in “Creating MobiLink users”.