Extending default function strings

You can use the rs_default_fs system variable with all function strings that have replication-definition scope (table or function) as a way to extend the default function-string behavior.

Using the rs_default_fs system variable reduces the amount of typing required when you want to keep the functionality of the default function string intact and include additional commands. For example, you can add commands to extend the capabilities of the default function string for auditing or tracking purposes.

Commands that you add to the output language template may either precede or follow the rs_default_fs system variable. They may or may not affect how the row is replicated into the replicate table.

The following example shows how you might use the rs_default_fs system variable in the create function string command (or the alter function string command) to verify that an update has occurred:

create function string replication_definition.rs_update
  for function_string_class
  output language '?rs_default_fs!sys?;
if (@@rowcount = 0)
  begin
  raiserror 99999 "No rows updated!"
  end'

In this example, the rs_default_fs system variable, embedded in the language output template, maintains the functionality of the default rs_update function string while the output template then checks to see if any rows have been updated. If they have not been updated, an error is raised.

In this example, the commands that follow the system variable do not affect how the row is to be replicated at the replicate site. You can use the rs_default_fs system variable with similar additional commands for verification or auditing purposes.