Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » MobiLink - Server Administration » Writing Synchronization Scripts

Table scripts Next Page

Script parameters


Most synchronization scripts can receive parameters from the MobiLink server. For details about the parameters you can use in each script, see Synchronization Events.

You can specify parameters in your SQL scripts in one of two ways:

Script parameters represented by question marks

Representing parameters with question marks is an ODBC convention. To use question marks in your MobiLink SQL scripts, place a single question mark in your script for each parameter. The MobiLink server replaces each question mark with the value of a parameter. It substitutes values in the order the parameters appear in the script definition.

The parameters must be in the order specified in the Synchronization Events chapter. Some parameters are optional. A parameter is optional only if no subsequent parameters are specified. For example, you must use parameter 1 if you want to use parameter 2.

See Synchronization Events.

Named script parameters

MobiLink provides named parameters that you can use instead of question marks in your scripts. Named parameters have the following advantages:

You cannot mix named parameters and question marks in a single script.

There are four types of MobiLink named parameters. To specify a named parameter, you must prefix it with its type, as follows:

Type of named parameterPrefixExamples
System parameters.s.{ml s.remote_id}
Row parameters. (The column name. If the column contains spaces, enclose it in double quotes or square brackets.)r.

{ml r.cust_id}

{ml r."Column name"}

Old row parameters. (Only used in upload_update scripts. If the column name contains spaces, enclose it in double quotes or square brackets.)o.

{ml o.cust_name}

{ml o."Column name"}

Authentication parameters. See Authentication parameters.a.{ml a.1}
User-defined parameters. See User-defined named parameters.u.{ml u.varname}

To reference a script parameter by name, enclose the parameter in curly braces and prefix it with ml, as in {ml parameter }. For example, {ml s.action_code}. The curly brace notation is an ODBC convention.

For convenience, you can enclose a larger section of code in the curly braces, as long as the section of code does not contain any schema names with the same name as a MobiLink script parameter. For example, both of the following upload_insert scripts are valid and equivalent:

INSERT INTO t ( id, c0 ) VALUES( {ml r.id}, {ml r.c0} )

and

{ml  INSERT INTO t ( id, c0 ) VALUES( r.id, r.c0 ) }
Note

To use named row parameters when the columns in your remote database were not generated by the MobiLink Create Synchronization Model wizard, you need to use the ml_add_column system procedure to store column information in the consolidated database. See ml_add_column.


User-defined named parameters
Authentication parameters