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, select Tools>Connect from the menu bar, select MobiLink Synchronization from the New Connection dialog box, and click OK.

  2. On the Identification page in the Connect dialog box, select ODBC DataSource Name, browse to select the DSN of the consolidated database, and click OK.

When you expand the node for a consolidated database in the MobiLink Synchronization plug-in, you see five folders: Tables, Connection Scripts, Synchronized Tables, Users, and Versions. 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.

NoteGlobal script version For MobiLink 10 and later, you can create a script version called ml_global that is used differently from other script versions. If you create a script version called ml_global, you define it once and then the connection scripts associated with it are used by default in all synchronizations. You never explicitly specify ml_global as a script version.

The ml_global script version can contain connection-level scripts only. For more information, see the MobiLink Server Administration book.

StepsTo add a script version:

  1. Select the Versions folder and double-click Add Version.

  2. In the Add a New Script Version dialog box, provide a name for the version and optionally a description, and click Finish.

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

Adding 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 synchronized table to a consolidated database:

  1. Select the Tables folder and double-click DBA.

  2. Right-click the table you want to add to the list of synchronized tables and select Add to Synchronized Tables from its pop-up menu.

StepsTo add a script to a synchronized table:

  1. Select the Synchronized Tables folder, select the table for which you want to add a script, and double-click Add Table Script.

  2. From the first drop-down list, select the version for which you want to add a script.

  3. From the second drop-down list, select the event for which you want to add a script.

    Events that already have a script do not appear in the drop-down list.

  4. From the third drop-down list, select the language in which you want to write a script.

  5. Make sure the Edit the Script of the New Event Immediately check box is selected and click Finish.

  6. 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 MobiLink Server Administration book.

StepsTo add a connection-level script:

  1. Select the Connection Scripts folder and double-click Add Connection Script.

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

Modifying scripts

To modify an existing script, navigate to the script in Sybase Central as described in the preceding procedures, then double-click the Edit icon to the left of the version name.

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, select the Users folder, double-click Add User, and complete the Add User wizard.

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