sp_hook_dbmlsync_logscan_end

Use this stored procedure to add custom actions immediately after the transaction log is scanned for upload.

Rows in #hook_dict table

Name

Value

Description

ending log offset (in)

number

The log offset value where scanning ended.

starting log offset_n (in)

number

The initial progress value for each subscription you synchronize. The n values correspond to those in Publication_n. For example, Starting log offset_1 is the offset for Publication_1.

log scan retry (in)

true | false

If this is the first time the transaction log has been scanned for this synchronization, the value is false; otherwise it is true. The log is scanned twice when the MobiLink server and dbmlsync have different information about where the scanning should begin.

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.

Remarks

If a procedure of this name exists, it is called immediately after dbmlsync has scanned the transaction log to assemble the upload.

Actions of this procedure are committed immediately after execution.

See also
Examples

Assume you use the following table to log synchronization events on the remote database.

CREATE TABLE SyncLog
(
 "event_id"          INTEGER NOT NULL DEFAULT AUTOINCREMENT ,
   "event_name"       VARCHAR(128) NOT NULL ,
   "ml_user"            VARCHAR(128) NULL ,
   "event_time"         TIMESTAMP NULL,
   "table_name"         VARCHAR(128) NULL ,
   "upsert_count"       VARCHAR(128) NULL ,
   "delete_count"       VARCHAR(128) NULL ,
   "exit_code"          INTEGER NULL ,
   "status_retval"      VARCHAR(128) NULL ,
   "pubs"                VARCHAR(128) NULL ,
   "sync_descr "         VARCHAR(128) NULL , 
    PRIMARY KEY ("event_id"),
);

The following example logs the MobiLink user and current timestamp immediately after the transaction log is scanned for upload. The #hook_dict log scan retry parameter indicates if the transaction log is scanned more than one time.

CREATE PROCEDURE sp_hook_dbmlsync_logscan_end ()
BEGIN

 DECLARE scan_retry VARCHAR(128);
    
 -- load the scan retry parameter from #hook_dict
 SELECT #hook_dict.value
  INTO scan_retry
  FROM #hook_dict
  WHERE #hook_dict.name = 'log scan retry';
 
 -- Determine if the log is being rescanned
 -- and log the synchronization event 

 IF scan_retry='true' THEN
   INSERT INTO SyncLog (event_name, ml_user,event_time,sync_descr)
    SELECT 'logscan_end', #hook_dict.value, CURRENT TIMESTAMP,
     'Transaction log rescanned'
    FROM #hook_dict
    WHERE name = 'MobiLink user' ;  
 ELSE
   INSERT INTO SyncLog (event_name, ml_user,event_time,sync_descr)
    SELECT 'logscan_end', #hook_dict.value, CURRENT TIMESTAMP,
     'Transaction log scanned normally'
    FROM #hook_dict
    WHERE name = 'MobiLink user' ;  
 END IF;
END;