The following guidelines for creating function strings pertain to function-string classes:
If you need to customize function strings, you can do so in any class other than the system-provided classes rs_default_function_class and rs_db2_function_class.
For rs_db2_function_class, rs_iq_function_class, rs_msss_function_class, and rs_oracle_function_class, you:
Cannot use function-string class scope system functions, such as rs_begin to create customized class-level function strings
Can use replication definition scope system functions such as rs_insert to create customized table-level function strings
You must assign a function-string class a primary site before you can create function strings for the class. The system-provided class rs_sqlserver_function_class has no primary site until you assign one using the create function string class command.
If the function-string class is a new base class, you must create function strings for all the necessary system functions before you can use the class.
The following guidelines pertain to function strings themselves:
You can specify an optional name for the function string. For the rs_select, rs_select_with_lock, rs_datarow_for_writetext, rs_get_textptr, rs_textptr_init, and rs_writetext functions, Replication Server uses the function-string name to uniquely identify the function strings. Function string names are unique when you qualify them fully.
If the input template is omitted for an rs_select or rs_select_with_lock function string, Replication Server matches any subscriptions that do not have matching function strings.
If you are customizing function strings for functions with replication-definition scope, you must create the function strings before you create the subscriptions.
You can put several commands in a language output template, separating them with semicolons. See “Defining multiple commands in a function string” for details.
You can batch commands for non-ASE servers. See “Command batching for non-ASE servers”.
Make sure that the database connection batch parameter has been set to allow command batching. See “Configuration parameters affecting individual connections” on page 193 in the Replication Server Administration Guide Volume 1.
You can use Adaptive Server syntax to specify a null value for a constant in a function string.
You can increase function string efficiency when you create or alter function strings by using the none parameter to identify class-level and table-level function strings that do not have output commands. Replication Server does not execute these function strings on replicate databases.
Refer to Chapter 3, “Replication Server Commands,” in the Replication Server Reference Manual for the complete syntax for the create function string command.
The following example creates a function string for the rs_begin function that begins a transaction in the database by executing a stored procedure named begin_xact.
create function string rs_begin for gateway_func_class output rpc 'execute begin_xact'
The following example creates a function string for a rs_insert function that references the publishers_rep replication definition, which executes an RPC at the replicate database as a result of an insert in the primary table. The stored procedure insert_publisher is defined only at the replicate database.
create function string publishers_rep.rs_insert for rs_sqlserver_function_class output rpc 'execute insert_publisher @pub_id = ?pub_id!new?, @pub_name = ?pub_name!new?, @city = ?city!new?, @state = ?state!new?'