Provides useful information about the publication(s) being synchronized.
In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.
In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated and it is recommended that you use named parameters. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you want to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.
Parameter name for SQL scripts | Description | Order (deprecated for SQL) |
---|---|---|
s.generation_number |
INTEGER. If your deployment does not use file-based downloads, this parameter can be ignored. The default value is 1. |
1 |
s.remote_id | VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. | Not applicable |
s.username |
VARCHAR(128). The MobiLink user name. |
2 |
s.publication_name |
VARCHAR(128). The name of the publication. |
3 |
s.last_publication_upload |
TIMESTAMP. Last successful upload time of this publication. |
4 |
s.last_publication_download |
TIMESTAMP. The last download time of this publication. |
5 |
s.subscription_id |
VARCHAR(128). The remote subscription ID. |
6 |
None.
This event lets you design synchronization logic based on the publications currently being synchronized. This event is invoked in the same transaction as the end_synchronization event, and is invoked before the end_synchronization event. It is invoked once per publication being synchronized.
If the current synchronization successfully applied an upload, the last_upload parameter contains the time this latest upload was applied. The last_publication_download is the same value that was passed to the download scripts as the last download time.
If an UltraLite remote database is synchronizing with UL_SYNC_ALL, this event is invoked once with the name 'unknown'.
The generation_number parameter is specifically for file-based downloads. In file-based downloads, changes to generation numbers are used to force an upload before the download when the file is applied at the remote. The number is stored in the download file.
The output value of the generation number is passed from the begin_publication script to the end_publication script. The meaning of the generation_number depends on whether the current synchronization is being used to create a download file, or whether the current synchronization has an upload.
You may want to record the information for each publication being synchronized. The following example calls ml_add_connection_script to assign the event to a stored procedure called RecordPubEndSync.
CALL ml_add_connection_script( 'version1', 'end_publication', 'CALL RecordPubEndSync( {ml s.generation_number}, {ml s.username}, {ml s.publication_name}, {ml s.last_publication_upload}, {ml s.last_publication_download} )' ); |
The following call to a MobiLink system procedure registers a Java method called endPublication as the script for the end_publication connection event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'end_publication', 'ExamplePackage.ExampleClass.endPublication' ) |
The following is the sample Java method endPublication. It outputs a message to the MobiLink message log. (Note that printing a message to the MobiLink message log might be useful at development time but would slow down a production server.)
package ExamplePackage; import java.sql.*; public class ExampleClass { String _curUser = null; public String endPublication( int generation_number, String user, String pub_name, Timestamp last_publication_upload, Timestamp last_publication_download ) { java.lang.System.out.println( "Finished synchronizing publication " + pub_name ); return ( null ); }} |
The following call to a MobiLink system procedure registers a .NET method called EndPub as the script for the end_publication connection event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'end_publication', 'TestScripts.Test.EndPub' ) |
The following is the sample .NET method endPub. It outputs a message to the MobiLink message log. (Note that printing a message to the MobiLink message log might be useful at development time but would slow down a production server.)
public string EndPub( int generation_number, string user, string pub_name, DateTime last_publication_upload, DateTime last_publication_download ) { System.Console.Write( "Finished synchronizing publication " + pub_name ); return ( null ); } |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |