Using function-string variables

Variables embedded in function-string input or output templates are symbolic markers for various runtime values.

A variable can represent a column name, the name of a system-defined variable, the name of a parameter in a user-defined function, or a user-defined variable defined in an input template. The variable must refer to a value with the same datatype as anything to which it is assigned.

Function-string variables are enclosed inside of a pair of question marks (?), as shown:

?variable!modifier?

The modifier portion of a variable identifies the type of data the variable represents. The modifier is separated from the variable name with an exclamation (!).

The rs_truncate function string accepts position-based function string variable in the format:

?n!param?

Where n is a number from 1 to 255, representing the position of function parameter in the LTL. The first parameter for rs_truncate in the LTL is represented in function string as ?1!param?. For position based function string variable, the only acceptable modifier is param.

A sample function string for rs_truncate with the position-based variable is as follows:

truncate table publishers partition ?1!param?

Replication Server recognizes the modifiers listed in Table 2-3:

Table 2-3: Function-string variable modifiers

Modifier

Description

new, new_raw

A reference to the new value of a column in a row that Replication Server is inserting or updating.

old, old_raw

A reference to the old values of a column in a row that Replication Server is inserting or updating.

user, user_raw

A reference to a variable that is defined in the input template of an rs_select or rs_select_with_lock function string.

sys, sys_raw

A reference to a system-defined variable.

param, param_raw

A reference to a stored-procedure parameter.

text_status

A reference to the text_status value for text, unitext, or image data. Possible values are:

  • 0x000 – Text field contains NULL value, and the text pointer has not been initialized.

  • 0x0002 – Text pointer is initialized.

  • 0x0004 – Real text data will follow.

  • 0x0008 – No text data will follow because the text data is not replicated.

  • 0x0010 – The text data is not replicated but it contains NULL values.

NoteFunction strings for user-defined functions may not use the new or old modifiers.

Refer to Chapter 3, “Replication Server Commands,” in the Replication Server Reference Manual for a list of system-defined variables that you can use in function-string input or output templates.

See “Using the default system variable” for information on applications for that system variable.