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:
named script parameters
question marks (deprecated in SQL scripts)
Named parameters have the following advantages over (deprecated) question marks:
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. | u. or ui. |
|
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, each of the following upload_insert scripts are valid and equivalent:
INSERT INTO t ( id, c0 ) VALUES( {ml r.id}, {ml r.c0} ) |
and
INSERT INTO t ( is, c0 ) VALUES({ml r.id, r.c0}) |
and
{ml INSERT INTO t ( id, c0 ) VALUES( r.id, r.c0 ) } |
To use named row parameters you may need to use the ml_add_column system procedure to store column information in the consolidated database, although most deployments using version 12 synchronization clients do not require this. See ml_add_column system procedure.
Representing parameters with question marks has been deprecated in SQL scripts. It is strongly recommended that you use named parameters instead. See Named script parameters and User-defined named 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.
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.
System parameter | Event type | Event parameter is available in |
---|---|---|
action_code |
connection |
The action_code parameter is available in the following events:
|
authentication_status |
connection |
The authentication_status parameter is available in the following events:
|
bytes |
connection and table |
The bytes parameter is available in the following events:
|
conflicted_deletes |
connection and table |
The conflicted_deletes parameter is available in the following events:
|
conflicted_inserts |
connection and table |
The conflicted_inserts parameter is available in the following events:
|
conflicted_updates |
connection and table |
The conflicted_updates parameter is available in the following events:
|
connection_retries |
connection |
The conflicted_retries parameter is available in the following events:
|
deadlocks |
connection and table |
The deadlocks parameter is available in the following events:
|
deleted_rows |
connection and table |
The deleted_rows parameter is available in the following events:
|
error_code |
connection |
The error_code parameter is available in the following events:
|
error_message |
connection |
The error_message parameter is available in the following events:
|
errors |
connection and table |
The errors parameter is available in the following events:
|
event_name |
connection and table |
The event_name parameter is available in the following events:
|
fetched_rows |
connection and table |
The fetched_rows parameter is available in the following events:
|
file_authentication_code |
connection |
The file_authentication_code parameter is available in the following events:
|
filename |
connection |
The filename parameter is available in the following events:
|
file_size |
connection |
The file_size parameter is available in the following events:
|
filtered_rows |
connection and table |
The filtered_rows parameter is available in the following events:
|
generation_number |
connection |
The filtered_rows parameter is available in the following events:
|
hashed_new_password |
connection |
The hashed_new_password parameter is available in the following events:
|
hashed_password |
connection |
The hashed_password parameter is available in the following events:
|
ignored_deletes |
connection and table |
The ignored_deletes parameter is available in the following events:
|
ignored_inserts |
connection and table |
The ignored_inserts parameter is available in the following events:
|
ignored_updates |
connection and table |
The ignored_updates parameter is available in the following events:
|
inserted_rows |
connection and table |
The inserted_rows parameter is available in the following events:
|
last_download |
connection |
The last_download parameter is available in the following events:
|
last_publication_download |
connection |
The last_publication_download parameter is available in the following events:
|
last_publication_upload |
connection |
The last_publication_upload parameter is available in the following events:
|
last_table_download |
table |
The last_table_download parameter is available in the following events:
|
maximum_time |
connection and table |
The maximum_time parameter is available in the following events:
|
minimum_time |
connection and table |
The minimum_time parameter is available in the following events:
|
new_password |
connection |
The new_password parameter is available in the following events:
|
next_last_download |
connection |
The next_last_download parameter is available in the following events:
|
number_of_calls |
connection and table |
The number_of_calls parameter is available in the following events:
|
odbc_state |
connection |
The odbc_state parameter is available in the following events:
|
password |
connection |
The password parameter is available in the following events:
|
publication_name |
connection |
The publication_name parameter is available in the following events:
|
remote_id |
connection and table |
The remote_id parameter is available in the following events:
|
remote_key |
connection |
The remote_key parameter is available in the following events:
|
subdir |
connection |
The subdir parameter is available in the following events:
|
subscription_id |
connection |
The subscription_id parameter is available in the following events:
|
synchronization_ok |
connection and table |
The synchronization_ok parameter is available in the following events:
|
synchronized_tables |
connection |
The synchronized_tables parameter is available in the following events:
|
table |
connection and table |
The table parameter is available in the following events:
|
total_time |
connection and table |
The total_time parameter is available in the following events:
|
updated_rows |
connection and table |
The updated_rows parameter is available in the following events:
|
username |
connection and table |
The username parameter is available in the following events:
|
warnings |
connection and table |
The warnings parameter is available in the following events:
|
User-defined named parameters
Authentication parameters
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |