Class in which to create function strings

When you create rs_select and rs_select_with_lock function strings for materialization, you create them in the function-string class that is assigned to the connection to the primary database from which you are selecting materialization data. If you are using bulk materialization, you do not need to create rs_select and rs_select_with_lock function strings for materialization.

When you create rs_select and rs_select_with_lock function strings for dematerialization, you create them in the function-string class that is assigned to the connection to the replicate database for which you are selecting data to be dematerialized. If you drop a subscription using drop subscription with the without purge option, you do not need rs_select and rs_select_with_lock function strings for dematerialization.

Example for rs_select function string

In the following example, a site subscribes to a specified publisher’s book titles through the replication definition titles_rep. There must be an rs_select function string with an input template that compares the publisher column in the pubs2 database’s titles table to a user-defined value that identifies the publisher.

The create function string command creates a function string with an input template that compares the publisher column pub_id to the user-defined variable ?pub_id!user?. For details on function-string variables, see “Using function-string variables”.

The input template matches any subscription with a where clause of the form where pub_id = constant. As a result, the output template, when it is used, includes the constant value. The output template selects materialization data from two different tables.

create function string titles_rep.rs_select;pub_id
    for sqlserver2_function_class
scan 'select * from titles where pub_id =
    ?pub_id!user?'
output language
    'select * from titles where pub_id =
    ?pub_id!user?
    union
    select * from titles.pending where pub_id =
    ?pub_id!user?'

See “Creating function strings” for details. Refer to the Replication Server Reference Manual for complete syntax.