Processes any required operations between the upload and download transactions.
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.last_download |
TIMESTAMP. The earliest last download time of any synchronized table. |
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 |
None.
The MobiLink server executes this script in a separate transaction, between the upload transaction and the start of the download transaction.
The following call to a MobiLink system procedure registers a SQL stored procedure called prepareForDownload as the script for the prepare_for_download event when synchronizing the script version ver1.
CALL ml_add_connection_script( 'ver1', 'prepare_for_download', 'CALL prepareForDownload( { ml s.username } )' ) |
The following is the sample SQL method prepareForDownload. This stored procedure prepares downloads for two tables. For example, it could take information from many tables and store it in temporary tables referenced by the download_cursor scripts for tables T1 and T2.
CREATE PROCEDURE prepareForDownload ( IN ts TIMESTAMP, IN "user" VARCHAR(128)) BEGIN CALL prepareT1Download( user, ts ); CALL prepareT2Download( user, ts ); END; |
The following call to a MobiLink system procedure registers a Java method called prepareForDownload as the script for the prepare_for_download event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'prepare_for_download', 'ExamplePackage.ExampleClass.prepareForDownload' ) |
The following is the sample Java method prepareForDownload. This method prepares downloads for two tables. For example, it could take information from many tables, plus other information accessible from Java, and store it in temporary tables referenced by the download_cursor scripts for tables T1 and T2.
public String prepareForDownload( Timestamp ts, String user ) { prepareT1ForDownload( _syncconn, user, ts ); prepareT2ForDownload( _syncconn, user, ts ); return( null ); } |
The following call to a MobiLink system procedure registers a .NET method called PrepareForDownload as the script for the prepare_for_download connection event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'prepare_for_download', 'TestScripts.Test.PrepareForDownload' ) |
The following is the sample .NET method PrepareForDownload. This method prepares downloads for two tables. For example, it could take information from many tables, plus other information accessible from .NET, and store it in temporary tables referenced by the download_cursor scripts for tables T1 and T2.
public string PrepareForDownload( DateTime ts, string user ) { PrepareT1ForDownload ( _syncConn, user, ts ); PrepareT2ForDownload ( _syncConn, user, ts ); return ( null ); } |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |