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

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements

SYNCHRONIZE statement [MobiLink]

Synchronizes a SQL Anywhere database with a MobiLink server. The synchronization options can be specified in the statement itself.

Syntax
SYNCHRONIZE {
PROFILE sync-profile-name [ MERGE sync-option [ ;... ] ]
| USING sync-option [ ;... ]
| START 
| STOP 
}
[ PORT port-number ]
[ VERBOSITY { LOW | NORMAL | HIGH } ]
[ TIMEOUT timeout ]
[ USER user-name IDENTIFIED BY password ]
sync-option : string
Parameters
  • sync-profile-name

    The name of the synchronization profile to use for this synchronization.

  • MERGE clause

    Use this clause to add or override synchronization profile options.

  • USING clause

    Use this clause to specify synchronization profile options when you are not using a synchronization profile.

  • sync-option

    A string of one or more synchronization profile option value pairs, separated by semicolons. For example, 'option1=value1;option2=value2'.

  • PORT clause

    Use this clause to specify the port number that the database server uses to communicate with the dbmlsync utility. The default is 4433.

  • VERBOSITY clause

    This clause controls the amount of information that is added to the synchronize_results and synchronize_parameters shared global temporary tables during synchronization.

    The following is a list of client API events that are returned by each VERBOSITY option.

    Option Returns
    LOW
    • DBSC_EVENTTYPE_SYNC_START
    • DBSC_EVENTTYPE_SYNC_DONE
    • DBSC_EVENTTYPE_ERROR_MSG
    • DBSC_EVENTTYPE_WARNING_MSG
    NORMAL (default)
    • DBSC_EVENTTYPE_SYNC_START
    • DBSC_EVENTTYPE_SYNC_DONE
    • DBSC_EVENTTYPE_ERROR_MSG
    • DBSC_EVENTTYPE_WARNING_MSG
    • DBSC_EVENTTYPE_INFO_MSG
    HIGH
    • DBSC_EVENTTYPE_SYNC_START
    • DBSC_EVENTTYPE_SYNC_DONE
    • DBSC_EVENTTYPE_ERROR_MSG
    • DBSC_EVENTTYPE_WARNING_MSG
    • DBSC_EVENTTYPE_INFO_MSG
    • DBSC_EVENTTYPE_PROGRESS_INDEX
    • DBSC_EVENTTYPE_PROGRESS_TEXT
    • DBSC_EVENTTYPE_TITLE

    Be careful not to confuse the VERBOSITY clause of the SYNCHRONIZE statement with the VERBOSITY option that you can specify in a synchronization profile. The VERBOSITY clause of the SYNCHRONIZE statement controls the type of events that are recorded in the synchronize_results and synchronize_parameters tables. The VERBOSITY option in a synchronization profile controls the number of DBSC_EVENTTYPE_INFO_MSG events that are generated during synchronization.

    SYNCHRONIZE PROFILE SalesData VERBOSITY NORMAL;
    SYNCHRONIZE PROFILE SalesData MERGE 'Verbosity=BASIC,ROW_DATA' VERBOSITY NORMAL;
  • TIMEOUT clause

    This clause specifies how long the database server waits, in seconds, for the synchronization to complete before attempting to cancel the synchronization. The default is 240 seconds.

  • USER/IDENTIFIED BY clause

    Use this clause to specify the database user ID and password that the dbmlsync utility uses to connect to the remote database to perform the synchronization. The user ID specified must have the SYS_RUN_REPLICATION_ROLE system role. By default, synchronization uses the user ID for the database connection that executed the SYNCHRONIZE statement.

  • START clause

    Starts the dbmlsync utility running in server mode and leaves it running. No synchronization is performed. When you are performing more than one synchronization in a short period, you can improve performance by explicitly starting the dbmlsync server using this clause, performing your synchronizations, then explicitly stopping the dbmlsync server using the STOP clause.

  • STOP clause

    Stops a dbmlsync server that was previously started using the START clause. No synchronization is performed.

Remarks

This statement can only be used if the MobiLink client for SQL Anywhere including the Dbmlsync C++ API is installed.

The MobiLink client for SQL Anywhere is not available on all platforms where the database server may run.

When synchronization is complete, you can view the results of the synchronization in the synchronize_results and synchronize_parameters shared global temporary tables. The synchronize_results and synchronize_parameters tables store the results of all synchronizations that have been executed with the SYNCHRONIZE statement since the database server was started. The synchronize_results and synchronize_parameters tables are truncated each time the database server is shut down.

The synchronize_results table contains the following columns:

Column name Data type Description
row_id UNSIGNED BIGINT The primary key of the table used to determine the order in which rows were inserted into the table.
conn_id UNSIGNED INT The connection id number of the connection that executed the SYNCHRONIZE statement that generated this event.
result_time TIMESTAMP The time the event was added to the synchronize_results table.
result_type CHAR(128) The type of event.

Each event shown in the synchronize_results table has 0 or more parameters associated with it that contain additional information about the event. The parameters are stored in the synchronize_parameters table, which contains the following columns:

Column name Data type Description
row_id UNSIGNED BIGINT A foreign key to the row_id column in the synchronize_results table. Use this value to match each parameter back to the event to which it belongs.
parm_id UNSIGNED INT Contains the numeric ID of the parameter. For events with more than 1 parameter, use this value to locate the specific parameter you need.
parm_message LONG VARCHAR The value associated with the parameter.

To view information about past or current synchronizations, you can use the sp_get_last_synchronize_result system procedure as an alternative to directly querying the synchronize_results and synchronize_parameters tables.

Alternately, you can use the following statement to view the results of all the synchronizations that have taken place since the database server was started.

SELECT *
     FROM synchronize_results sr
     KEY JOIN synchronize_parameters sp
     ORDER BY sr.row_id , sp.parm_id

You can use the synchronize_results and synchronize_parameters tables to monitor the progress of a synchronization on a connection that is different from your current connection. To monitor the progress of a synchronization on a different connection:

  • Execute a SELECT CONNECTION_PROPERTY statement to determine the connection ID of the current connection.

  • Execute a SYNCHRONIZE statement to start synchronization.

  • On a separate connection, use the sp_get_last_synchronize_results system procedure to retrieve results using the connection ID you determined above.

To view the results of a synchronization that is complete or in progress on a specific connection, you can use the sp_get_last_synchronize_results system procedure.

The SYNCHRONIZE statement is similar to the UltraLite SYNCHRONIZE statement. However, the SQL Anywhere SYNCHRONIZE statement launches the dbmlsync utility in server mode to perform the synchronization. The UltraLite SYNCHRONIZE statement uses UltraLite runtime.

In cases where there are multiple versions of SQL Anywhere installed on the same system, or if the dbmlsync executable is not located in the same directory as the database server and cannot be found in the PATH environment variable, use the ALTER EXTERNAL ENVIRONMENT command to specify the location of the dbmlsync executable.

The database server functions as a dbmlsync API client and uses TCP/IP to communicate with a dbmlsync server. By default, this communication occurs on port 4433. Use the PORT clause to specify a different port.

Use the SYNCHRONIZE PROFILE and SYNCHRONIZE USING statements to perform a synchronization. Use the SYNCHRONIZE START and SYNCHRONIZE STOP statements to start or stop a dbmlsync server. When executing a SYNCHRONIZE PROFILE or SYNCHRONIZE USING statement, the database server attempts to connect to a dbmlsync server that is already running. If a dbmlsync server that is already running cannot be located, a dbmlsync server is started. When the synchronization is complete, the database server shuts down the dbmlsync server it started. If the statement connected to a dbmlsync server that was already running, the dbmlsync server is not shut down. If you are performing multiple synchronizations and do not want to start and stop the dbmlsync server for each synchronization, you can execute a SYNCHRONIZE START statement, followed by multiple SYNCHRONIZE PROFILE or SYNCHRONIZE USING statements, and end with a SYNCHRONIZE STOP statement.

If you use this statement in a procedure, do not specify the password as a string literal because the definition of the procedure is visible in the SYSPROCEDURE system view. For security purposes, specify the password using a variable that is declared outside of the procedure definition.

Privileges

You must have either the MANAGE REPLICATION system privilege or the SYS_RUN_REPLICATION_ROLE system role.

Side effects

None

Standards
  • ANSI/ISO SQL Standard

    Not in the standard.

Example

The following example shows the syntax for synchronizing a synchronization profile named Test1:

SYNCHRONIZE PROFILE Test1;