Use this stored procedure to add custom actions immediately after each table is downloaded.
Name |
Value |
Description |
---|---|---|
table name (in) |
table name |
The table to which operations have just been applied. |
delete count (in) |
number of rows |
The number of rows in this table deleted by the download. |
upsert count (in) |
number of rows |
The number of rows in this table updated or inserted by the download. |
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 immediately after all operations in the download for a table have been applied.
Actions of this procedure are committed or rolled back when the download is committed or rolled back.
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, the table name and the number of inserted or updated rows immediately after a table is downloaded.
CREATE PROCEDURE sp_hook_dbmlsync_download_table_end() BEGIN -- declare variables DECLARE tbl VARCHAR(255); DECLARE upsertCnt VARCHAR(255); DECLARE deleteCnt VARCHAR(255); -- load the table name from #hook_dict SELECT #hook_dict.value INTO tbl FROM #hook_dict WHERE #hook_dict.name = 'table name'; -- load the upsert count from #hook_dict SELECT #hook_dict.value INTO upsertCnt FROM #hook_dict WHERE #hook_dict.name = 'upsert count'; -- load the delete count from #hook_dict SELECT #hook_dict.value INTO deleteCnt FROM #hook_dict WHERE #hook_dict.name = 'delete count'; INSERT INTO SyncLog (event_name, ml_user, table_name, upsert_count, delete_count, event_time) SELECT 'download_table_end', #hook_dict.value, tbl, upsertCnt, deleteCnt, CURRENT TIMESTAMP FROM #hook_dict WHERE name = 'MobiLink user' ; END; |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |