Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 » MobiLink - Server Administration » MobiLink Events » Writing synchronization scripts


Writing scripts to download rows

There are two scripts that can be used for processing each table during the download transaction. These are the download_cursor script, which performs inserts and updates, and the download_delete_cursor script, which performs deletes.

These scripts are either SELECT statements or calls to procedures that return result sets. The MobiLink server downloads the result set of the script to the remote database. The MobiLink client automatically inserts or updates rows based on the download_cursor script result set, and deletes rows based on the download_delete_cursor event.

For more information about using stored procedures, see Downloading a result set from a stored procedure call.

The MobiLink server downloads data in a single transaction. For a description of the download process, see Events during download.

  • Like the upload, the download starts and ends with connection events. Other events are table-level events.

  • If you change the SendDownloadAck setting to ON, the server behavior depends on the download acknowledgement mode you are using. For blocking download acknowledgement, if no confirmation of the download is received from the client, the entire download transaction is rolled back in the consolidated database. For non-blocking download acknowledgement, the download transaction is committed but the download timestamp update and acknowledgement scripts are not executed until the acknowledgement is received.

    By default, SendDownloadAck is set to OFF.

    See SendDownloadACK (sa) extended option, Send Download Acknowledgement synchronization parameter, -nba option, nonblocking_download_ack connection event and publication_nonblocking_download_ack connection event.

  • The begin_download and end_download scripts for each remote table hold logic that is independent of the individual rows being updated.

  • For timestamp-based downloads, you specify the last_download_timestamp parameter to ensure that only changes since the last synchronization are downloaded. For example, the download_cursor or download_delete_cursor SQL script could include the line:

    WHERE Customer.last_modified >= {ml s.last_table_download}

    See Using last download times in scripts.

  • The download does not distinguish between inserts and updates. The script associated with the download_cursor event is a SELECT statement that defines the rows to be downloaded. The client detects whether the row exists or not and then it performs the appropriate insert or update operation.

  • At the end of the download processing, the client automatically deletes rows if necessary to avoid referential integrity violations.


Do not synchronize shadow tables that were created by previous deployments (for example, tables ending with _mod or _del should not be synchronized). These tables are only needed by the consolidated database to track modified or deleted rows.

See Referential integrity and synchronization.

Writing download_cursor scripts
Writing download_delete_cursor scripts