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

SQL Anywhere 17 » MobiLink and SAP HANA Remote Data Sync - Client Administration » SQL Anywhere clients for MobiLink » Event hooks for SQL Anywhere clients


Use this stored procedure to add custom actions immediately before synchronization is complete.

Rows in #hook_dict table
Name Value Description

restart (out)

sync | download | none

If set to sync, then dbmlsync retries the synchronization it just completed. The value sync replaces true, which is identical but is deprecated.

If set to none (the default), then dbmlsync shuts down or restarts according to its command line arguments. The value none replaces false, which is identical but is deprecated.

If set to download and the restartable download parameter is true, then dbmlsync attempts to restart the download that just failed.

exit code (in)


The exit code for the synchronization just completed. A value other than zero represents a synchronization error.

publication_n (in)


Deprecated. Use subscription_n instead. The publications being synchronized, where n is an integer. There is one publication_n entry for each publication being synchronized. The numbering of n starts at zero.

MobiLink user (in)

MobiLink user name

The MobiLink user for which you are synchronizing.

upload status (in)

not sent | committed | failed | unknown

Specifies the status returned by the MobiLink server when dbmlsync attempted to verify receipt of the upload. The status can be:

  • not sent - No upload was sent to the MobiLink server, either because an error prevented it or because the requested synchronization did not require it. This can occur during a download-only synchronization, a restarted download, or a file-based download.
  • committed - The upload was received by the MobiLink server, and committed.
  • failed - The MobiLink server did not commit the upload. For a transactional upload, the upload status is 'failed' when some but not all the transactions were successfully uploaded and acknowledged by the server.
  • unknown - The upload was not acknowledged by the MobiLink server. There is no way to know if it was committed or not.

script version (in)

script version name

The MobiLink script version to be used for the synchronization.

restartable download (in) true|false

If true, the download for the current synchronization failed and can be restarted. If false, the download was successful or it cannot be restarted.

restartable download size (in) integer

When the restartable download parameter is true, this parameter indicates the number of bytes that were received before the download failed. When restartable download is false, this value is meaningless.

error hook user state (in) integer

This value contains information about errors and can be sent from the hooks sp_hook_dbmlsync_all_error, sp_hook_dbmlsync_communication_error, sp_hook_dbmlsync_misc_error, or sp_hook_dbmlsync_sql_error.

subscription_n (in) subscription name(s) The names of subscriptions being synchronized where n is an integer. This is one subscription_n entry for each subscription being synchronized. The numbering of n starts at zero.

If a procedure of this name exists, it is called at the end of each synchronization.

If an sp_hook_dbmlsync_end hook is defined so that the hook always sets the restart parameter to sync, and you specify multiple subscriptions on the dbmlsync command line in the form -s sub1, -s sub2, and so on, then dbmlsync repeatedly synchronizes the first publication and never synchronizes the second.

Actions of this procedure are committed immediately after execution.


Hook procedures can be created by any user with the MANAGE REPLICATION system privilege. However, to ensure that the hook can access the #hook_dict table, which is used to pass information in and out of hooks, hooks must meet one of the following requirements:

  • Be owned by a user with the SELECT ANY TABLE and UPDATE ANY TABLE system privileges.

  • Be defined using the SQL SECURITY INVOKER clause of the CREATE PROCEDURE statement.


In the following example the download is manually restarted if the download for the current synchronization failed and can be restarted.

CREATE PROCEDURE sp_hook_dbmlsync_end()
  -- Restart the download if the download for the current sync
  --  failed and can be restarted  
  IF EXISTS (SELECT * FROM #hook_dict
    WHERE name = 'restartable download' AND value='true')
   UPDATE #hook_dict SET value ='download' WHERE name='restart';