When you use download acknowledgement, this script provides a place to record the information that a publication has been successfully downloaded.
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.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. |
1 |
s.last_publication_download |
TIMESTAMP. The earliest last download time of any synchronized table. |
2 |
s.publication name | VARCHAR(128). The name of the publication. | 3 |
s.subscription_id | VARCHAR(128). The remote subscription ID. | 4 |
This event lets you record the time when the download of this publication was successfully applied at the remote database.
This event is only called when using download acknowledgement. When in non-blocking mode, the download transaction is committed and the synchronization ends when the download is sent. When the synchronization client acknowledges a successful download, this event is called once per publication in the download. This event is called on a new connection and after the end_synchronization script of the original synchronization. The actions of this event are committed along with an update to the download time in the MobiLink system tables.
If the download is unsuccessful or if the network connection is dropped, there is no acknowledgement and this script is not invoked. If timely download acknowledgement is critical to your business needs, you should use the last_download parameter of the prepare_for_download script or the last_publication_download parameter of the begin_publication script as backups for your download acknowledgement processing.
Due to the special nature of this script, any connection-level variables set during the synchronization are not available when this event is executed.
The following script adds a record to a table called download_pubs_acked. The record contains the publication name, the first authentication parameter, and a download timestamp.
INSERT INTO download_pubs_acked( pub_name, auth_parm, last_download ) VALUES( {ml s.publication_name}, {ml a.1}, {ml s.last_publication_download} ) |
The following call to a MobiLink system procedure registers a Java method called publicationDownloadACK as the script for the publication_nonblocking_download_ack connection event when synchronizing the script version ver1.
CALL ml_add_java_connection_script ( 'ver1', 'publication_nonblocking_download_ack', 'ExamplePackage.ExampleClass.publicationDownloadACK' ) |
The following is the sample Java method publicationDownloadACK. It performs some business logic by acting on the confirmation if a particularly important publication was downloaded.
public String publicationDownloadACK( String user, Timestamp ldt, String pubName ) { if( pubName.equals( "MyImportantPublication" ) ) { actOnConfirmedDownload( user, ldt ); } return ( null ); } |
The following call to a MobiLink system procedure registers a .NET method called EndTableDownload as the script for the end_download table event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'publication_nonblocking_download_ack', 'TestScripts.Test.EndTableDownload' ) |
The following is the sample .NET method EndTableDownload. It performs some business logic by acting on the confirmation if a particularly important publication was downloaded.
public string EndTableDownload string user, DateTime ldt, string pub_name ) { if( pub_name.Equals( "MyImportantPublication" ) ) { ActOnConfirmedDownload( user, ldt ); } return ( null ); } |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |