Executing a script manually on a SQL Anywhere client

Any script may be executed manually. For SQL Anywhere clients, scripts are executed manually using the sync_get_next_passthrough_script and sync_execute_next_passthrough_script functions.

The sync_get_next_passthrough_script function takes no parameters and returns the run_order of the next script to be executed. You can then find out about that script by querying the dbo.sync_passthrough_script table.

dbo.sync_passthrough_script table

The dbo.sync_passthrough_script table is defined as follows:

Column name Description
run_order

INTEGER. The run_order parameter determines the order in which scripts are applied on the remote database. Scripts are always applied in order by run_order.

This value must be a non-negative integer.

script_id

INTEGER. This value uniquely identifies the script.

script_name

VARCHAR(128). The name of the script. This column corresponds to the script_name value specified for the script when ml_add_passthrough_script was called on the consolidated database.

flags

BIGINT. The flags column contains the information specified in the flags parameter passed to the ml_add_passthrough_script stored procedure. The flags specified are encoded into an integer by converting each specified flag into the value shown below, and combining the resultant values together with OR operators.

  • manual   Indicates that the script may only be run in manual execution mode. By default, all scripts can be run in either automatic or manual execution modes.

  • exclusive   Indicates that the script may only be automatically executed at the end of a synchronization where exclusive locks were obtained on all tables being synchronized. This option is ignored if the affected_ publications value lists no publications. This option is only meaningful to SQL Anywhere remotes.

  • schema_diff   Indicates that the script should be run in schema-diffing mode. In this mode, the database schema is altered to match the schema described in the script. For example, a create statement for an existing table is treated as an alter statement. This flag only applies to scripts run on UltraLite remotes.

affected_pubs

LONG VARCHAR. A list of publications that must be synchronized before the script is run. This column corresponds to the affected_pubs value specified for the script when ml_add_passthrough_script was called.

script

LONG VARCHAR. The contents of the passthrough script. This column corresponds to the script value specified for the script when ml_add_passthrough_script was called.

description

VARCHAR(2000). A comment or description of the script. This column corresponds to the description value specified for the script when ml_add_passthrough_script was called.

The sync_get_next_passthrough_script function returns null if there are no more scripts to execute or if the last script executed generated an error and no instructions on how to proceed have yet be received from the server.

The sync_execute_next_passthrough_script function takes no parameters. It executes the next script and updates progress and status information in the database so that the results of the script can be uploaded to the consolidated database later. No script is executed if the last script returned an error and no instructions have yet been received from the MobiLink server on how to handle the error. If a script is executed, the run order of that script is returned. If no script is executed, null is returned. See Capturing script results.