Define Multiple Commands in a Function String

You can use function strings to batch commands for database servers.

Language output templates can contain many commands. Adaptive Server permits multiple commands in a batch. Although most other data servers do not offer this feature, Replication Server allows you to batch commands in function strings for any data server by separating commands with a semicolon (;).

Use two consecutive semicolons (;;) to represent a semicolon that is not to be interpreted as a command separator.

If the data server supports command batches, Replication Server replaces the semicolons with the DSI command separator character (dsi_cmd_separator configuration parameter), as necessary, and submits the commands in a single batch.

If the data server does not support command batches, Replication Server submits each command in the function string separately.

For example, the output template in the following function string contains two commands:
create function string rs_commit
for sqlserver2_function_class
output language
'execute rs_update_lastcommit
    @origin = ?rs_origin!sys?,
    @origin_qid = ?rs_origin_qid!sys?,
    @secondary_qid = ?rs_secondary_qid!sys?;
    commit transaction'

Support for batches is enabled or disabled in Replication Server with the alter connection command.

Set batch to “on” to allow command batching for a database, or set it to “off” to send individual commands to the data server.

To set batching “on” for this example, enter:
alter connection to SYDNEY_DS.pubs2
	set batch to 'on'
To set batching “off,” enter:
alter connection to SYDNEY_DS.pubs2
	set batch to 'off'