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

SQL Anywhere 17 » MobiLink - Server Administration » MobiLink events » Synchronization events

download_delete_cursor table event

A data script that defines a cursor to select rows that are to be deleted in the remote database.


In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated. Use named parameters instead. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you are going to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts Description Order (deprecated for SQL)


TIMESTAMP. The last download time for the table.


s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable


VARCHAR(128). The MobiLink user name.


s.script_version VARCHAR(128). Optional IN parameter to specify that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter. Not applicable
Default action



The MobiLink server opens a read-only cursor to fetch a list of rows to download, and then delete from the remote database. This script must contain a SELECT statement that returns the primary key values of the rows to be deleted from the table in the remote database.

You can have one download_delete_cursor script for each table in the remote database.

If the download_delete_cursor has nulls for the primary key columns for one or more rows in a table, then the MobiLink server tells the remote database to delete all the rows in the table.

Rows deleted from the consolidated database cannot appear in a result set defined by a download_delete_cursor event, and so are not automatically deleted from the remote database. One technique for identifying rows to be deleted from remote databases is to add a column to the consolidated database table identifying a row as inactive.

To avoid downloading unnecessary rows to delete, consider using timestamp-based downloads. Include a line similar to the following in the WHERE clause of your download_delete_cursor script:

AND last_modified >= {ml s.last_table_download}

This script must be implemented in SQL. For Java or .NET processing of rows, use Direct row handling.

It can be problematic using READPAST table hints in a download_delete_cursor. For details, see the download_cursor event.

SQL example

This example is taken from the Contact sample and can be found in Samples\MobiLink\Contact\build_consol.sql. It deletes from the remote database any customers who have been changed since the last time this user downloaded data (Customer.last_modified >= {ml s.last_table_download}), and either

  • do not belong to the synchronizing user (SalesRep.username != {ml s.username}), or

  • are marked as inactive in the consolidated database ( = 0).

    CALL ml_add_table_script(
     'SELECT cust_id FROM Customer key join SalesRep
      WHERE Customer.last_modified >= {ml s.last_table_download} AND
       ( SalesRep.username != {ml s.username} OR = 0 )')