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:
question marks
named script parameters
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 Synchronization events. 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.
MobiLink provides named parameters that you can use instead of question marks in your scripts. Named parameters have the following advantages:
Named parameters allow you to specify any subset of the available parameters in any order.
With the exception of in/out parameters, you can specify the same named parameter more than once within a script.
When you use named parameters, you can specify the remote ID in your scripts. This is the only way to specify the remote ID in scripts.
You can create your own named parameters. See User-defined named parameters.
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 parameter | Prefix | Examples |
---|---|---|
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 to specify the pre-image column values. 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. | ui. | {ml ui.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 ) } |
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 system procedure.
The following forms of comments are recognized:
Double hyphen prefix (--)
Double forward slash prefix (//)
Block commenting (/* */)
The first two forms cause the script text to be ignored until the end of a line. The third form causes all script text between the /* prefix and the */suffix to be ignored. Block commenting cannot be nested.
Any other type of vendor-specific comment is not recognized and should not be used to comment references to a named parameter.
User-defined named parameters
Authentication parameters
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |