MobiLink Synchronization User's Guide
Adaptive Server Anywhere Clients
Customizing the client synchronization process
Using event-hook procedures
Each hook receives parameter values. In some cases, you can modify the value to return a new value; others are read-only.
These parameters are exchanged by reading and modifying rows in the #hook_dict table, which is defined as follows.
CREATE TABLE #hook_dict ( name VARCHAR( 128 ) NOT NULL UNIQUE, value VARCHAR( 255 ) NOT NULL )
Each row in the table contains the value for one parameter.
Before calling any of the stored procedures, dbmlsync creates the #hook_dict table, and adds the parameters for that event. Procedures can read the values by selecting from this table.
Some parameters can be used to pass values back to dbmlsync from the hook. The hook passes values back by updating the #hook_dict table.
For a list of the parameter values supplied at each event, see Client event-hook procedures.
The following examples illustrate how to retrieve and set values in the #hook_dict table.
The following sample sp_hook_dbmlsync_delay procedure illustrates the use of the #hook_dict table to pass arguments. The procedure allows synchronization only outside a scheduled down time of the MobiLink system between 18:00 and 19:00.
CREATE PROCEDURE sp_hook_dbmlsync_delay() BEGIN DECLARE delay_val integer; SET delay_val=DATEDIFF( second, CURRENT TIME, '19:00'); IF (delay_val>0 AND delay_val<3600) THEN UPDATE #hook_dict SET value=delay_val WHERE name='delay duration'; END IF; END
The following procedure is executed in the remote database at the beginning of synchronization. It retrieves the current MobiLink user name, one of the parameters available for the sp_hook_dbmlsync_begin event, and displays it on the console.
CREATE PROCEDURE sp_hook_dbmlsync_begin() BEGIN DECLARE syncdef VARCHAR(128); SELECT '>>>syncdef = ' || value INTO syncdef FROM #hook_dict WHERE name ='MobiLink user name'; MESSAGE syncdef TYPE INFO TO CONSOLE; END