Immediately before a hook is called, dbmlsync creates the #hook_dict table in the remote database, using the following CREATE statement. The # before the table name means that the table is temporary.
CREATE TABLE #hook_dict( name VARCHAR(128) NOT NULL UNIQUE, value VARCHAR(10240) NOT NULL) |
The dbmlsync utility uses the #hook_dict table to pass values to hook functions, and hook functions use the #hook_dict table to pass values back to dbmlsync.
Each hook receives parameter values. Sometimes, you can modify the value to return a new value; others are read-only. Each row in the table contains the value for one parameter.
For example, suppose two subscriptions are defined as follows:
CREATE SYNCHRONIZATION SUBSCRIPTION sub1 TO pub1 FOR MyUser; SCRIPT VERSION 'v1' |
CREATE SYNCHRONIZATION SUBSCRIPTION sub2 TO pub2 FOR MyUser; SCRIPT VERSION 'v1' |
When the sp_hook_dbmlsync_begin hook is called for the following dbmlsync command line
dbmlsync -c 'dsn=MyDsn' -s sub1,sub2 |
the #hook_dict table contains the following rows:
#hook_dict row | Value |
---|---|
subscription_0 |
sub1 |
subscription_1 |
sub2 |
publication_0 |
pub1 |
publication_1 |
pub2 |
MobiLink user |
MyUser |
Script version |
v1 |
The publication_n rows are deprecated and may be removed in a future release.
A hook can retrieve values from the #hook_dict table and use them to customize behavior. For example, to retrieve the MobiLink user you would use a SELECT statement like this:
SELECT value FROM #hook_dict WHERE name = 'MobiLink user' |
In/out parameters can be updated by your hook to modify the behavior of dbmlsync. For example, in the sp_hook_dbmlsync_abort hook you could instruct dbmlsync to abort synchronization by updating the abort synchronization row of the table using a statement like this:
UPDATE #hook_dict SET value='true' WHERE name='abort synchronization' |
The description of each hook lists the rows in the #hook_dict table.
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |