Use this stored procedure to control when synchronization takes place.
Name |
Value |
Description |
---|---|---|
delay duration (in|out) |
number of seconds |
If the procedure sets the delay duration value to zero, then dbmlsync synchronization proceeds. A non-zero delay duration value specifies the number of seconds before the delay hook is called again. |
maximum accumulated delay (in|out) |
number of seconds |
The maximum accumulated delay specifies the maximum number of seconds delay before each synchronization. Dbmlsync keeps track of the total delay created by all calls to the delay hook since the last synchronization. If no synchronization has occurred since dbmlsync started running, the total delay is calculated from the time dbmlsync started up. When the total delay exceeds the value of maximum accumulated delay, synchronization begins without any further calls to the delay hook. |
publication_n (in) |
publication |
The publications being synchronized, where n is an integer. There is one publication_n entry for each publication being uploaded. The numbering of n starts at zero. |
MobiLink user ( in ) |
MobiLink user name |
The MobiLink user for which you are synchronizing. |
script version (in) |
script version name |
The MobiLink script version to be used for the synchronization. |
If a procedure of this name exists, it is called before sp_hook_dbmlsync_begin at the beginning of the synchronization process.
Actions of this procedure are committed immediately after execution.
Assume you have the following table to log orders on the remote database.
CREATE TABLE OrdersTable( "id" INTEGER PRIMARY KEY DEFAULT AUTOINCREMENT, "priority" VARCHAR(128) ); |
The following example delays synchronization for a maximum accumulated delay of one hour. Every ten seconds the hook is called again and checks for a high priority row in the OrdersTable. If a high priority row exists, the delay duration is set to zero to start the synchronization process.
CREATE PROCEDURE sp_hook_dbmlsync_delay() BEGIN -- Set the maximum delay between synchronizations -- or before the first synchronization starts to 1 hour UPDATE #hook_dict SET value = '3600' // 3600 seconds WHERE name = 'maximum accumulated delay'; -- check if a high priority order exists in OrdersTable IF EXISTS (SELECT * FROM OrdersTable where priority='high') THEN -- start the synchronization to process the high priority row UPDATE #hook_dict SET value = '0' WHERE name='delay duration'; ELSE -- set the delay duration to call this procedure again -- following a 10 second delay UPDATE #hook_dict SET value = '10' WHERE name='delay duration'; END IF; END; |
In the sp_hook_dbmlsync_end hook you can mark the high priority row as processed:
CREATE PROCEDURE sp_hook_dbmlsync_upload_end() BEGIN IF EXISTS( SELECT value FROM #hook_dict WHERE name = 'Upload status' AND value = 'committed' ) THEN UPDATE OrderTable SET priority = 'high-processed' WHERE priority = 'high'; END IF; END; |
See sp_hook_dbmlsync_end.
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |