Contents Index Client event-hook procedures sp_hook_dbmlsync_begin

MobiLink Synchronization Reference
  Stored Procedures
    Client event-hook procedures

sp_hook_dbmlsync_abort


Function 

Use this stored procedure to cancel the synchronization process; or to log exit codes.

Rows in #hook_dict table  
Name Values Description
abort synchronization (in|out) True | False If you set the abort synchronization row of the #hook_dict table to true, then dbmlsync terminates immediately after the event.
publication_n (in) publication name The publications being synchronized, where n is an integer. There is one publication_n entry for each publication being uploaded.
MobiLink user (in) MobiLink user name The MobiLink user for which you are synchronizing.
return code (in) number When abort synchronization is set to TRUE, you can use this value to set the return code for the aborted synchronization. 0 indicates a successful synchronization. Any other number indicates that the synchronization failed.
script version (in) script version name The MobiLink script version to be used for the synchronization.
Description 

If a procedure of this name exists, it is called at dbmlsync startup, and then again after each synchronization delay that is caused by the sp_hook_dbmlsync_delay hook.

If the hook requests an abort by setting the abort synchronization value to true, the exit code is passed to the sp_hook_dbmlsync_process_exit_code hook. If no sp_hook_dbmlsync_process_exit_code hook is defined, the exit code is used as the exit code for the program.

Actions of this procedure are committed immediately after execution.

See also 

Synchronization event hook sequence

sp_hook_dbmlsync_process_return_code

Examples 

The following procedure prevents synchronization during a scheduled maintenance hour between 19:00 and 20:00 each day.

create procedure sp_hook_dbmlsync_abort()
begin
  declare down_time_start time;
  declare is_down_time varchar(128);
  set down_time_start='19:00';
  if abs( datediff( hour,down_time_start,now(*) ) ) < 1
  then
    set is_down_time='true';
  else
    set is_down_time='false';
  end if;
  UPDATE #hook_dict
  SET value = is_down_time
  WHERE name = 'abort synchronization'
end

Suppose you have an abort hook that may abort synchronization for one of two reasons. One of the reasons indicates normal completion of synchronization, so you want dbmlsync to have an exit code of 0. The other reason indicates an error condition, so you want dbmlsync to have a non-zero exit code. You could achieve this with an sp_hook_dbmlsync_abort hook defined as follows.

BEGIN
   IF [condition that defines the normal abort case] THEN
      UPDATE #hook_dict SET value =  '0' WHERE name = 'return code';
      UPDATE #hook_dict SET value =  'TRUE' WHERE name = 'abort synchronization';
   ELSEIF [condition that defines the error abort case] THEN
      UPDATE #hook_dict SET value =  '1' WHERE name = 'return code';
      UPDATE #hook_dict SET value =  'TRUE' WHERE name = 'abort synchronization';
   END IF;   
END;

Contents Index Client event-hook procedures sp_hook_dbmlsync_begin