Processes statements related to a specific table at the beginning of the synchronization.
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.table |
VARCHAR(128). The table name. |
2 |
s.new_remote_id | VARCHAR(128). The MobiLink remote ID, if the remote ID is new in the consolidated database. If the remote ID is not new, the value is null. | |
s.new_username | VARCHAR(128). The MobiLink user name, if the user name is new in the consolidated database. If the user name is not new, the value is null. |
None.
The MobiLink server executes this event after receiving everything from the MobiLink client that is required to begin synchronization.
You can have one begin_synchronization script for each table in the remote database. The event is only invoked when the table is synchronized.
The begin_synchronization table event is used to set up the synchronization of a particular table. The following SQL script registers a script that creates a temporary table for storing rows during synchronization. This syntax is for a SQL Anywhere consolidated database.
CALL ml_add_table_script( 'ver1', 'sales_order', 'begin_synchronization', 'CREATE TABLE #sales_order ( id integer NOT NULL default autoincrement, cust_id integer NOT NULL, order_date date NOT NULL, fin_code_id char(2) NULL, region char(7) NULL, sales_rep integer NOT NULL, PRIMARY KEY (id), )' ) |
The following call to a MobiLink system procedure registers a Java method called beginSynchronizationTable as the script for the begin_synchronization table event when synchronizing the script version ver1.
CALL ml_add_java_table_script( 'ver1', 'table1', 'begin_synchronization', 'ExamplePackage.ExampleClass.beginSynchronizationTable' ) |
The following is the sample Java method beginSynchronizationTable. It adds the current table name to a list of table names contained in this instance.
package ExamplePackage; import java.util.ArrayList; import java.sql.Timestamp; class ExampleClass { ArrayList<String> _tableList; String _curTable; public void beginSynchronizationTable( String user, String table ) { _curTable = table; _tableList.add( table ); } public void endTableDownload( Timestamp ts, String user, String table ) { _curTable = null; } } |
The following call to a MobiLink system procedure registers a .NET method called BeginTableSync as the script for the begin_synchronization table event when synchronizing the script version ver1 and the table table1.
CALL ml_add_dnet_table_script ( 'ver1', 'table1', 'begin_synchronization', 'TestScripts.Test.BeginTableSync' ) |
The following is the sample .NET method BeginTableSync. It adds the current table name to a list of table names contained in this instance.
using System.Collections.Generic; using System; namespace TestScripts { class Test { List<string> _tableList = new List<string>(); string _curTable = ""; public void BeginSynchronizationTable( string user, string table ) { _curTable = table; _tableList.Add( table ); } public void EndTableDownload( DateTime timestamp, string user, string table ) { _curTable = null; } } } |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |