create request function replication definition

Description

Creates a request function replication definition and a user-defined function for a stored procedure that is to be replicated. The request function is applied at the replicate database by the same user who executes the stored procedure at the primary database.

Syntax

create request function replication definition repdef_name
        with primary at dataserver.database
        with primary function named ‘func_name’
        with replicate function named ‘func_name’
        ([@param_name datatype [, @param_name datatype]…])
        [searchable parameters (@param_name [, @param_name]…)]
         [send standby {all | replication definition} parameters]

Parameters

repdef_name

The function replication definition name. The name must conform to the rules for identifiers.

with primary at

Specifies the data server and database that contains the primary data.

dataserver

The name of the data server that contains the primary data. If the primary database is part of a warm standby application, dataserver is the logical data server name.

database

The name of the database that contains the primary data. If the primary database is part of a warm standby application, database is the logical database name.

with primary function named

Specifies the stored procedure name at the primary database. If you do not specify a primary function name, Replication Server uses the replication definition name as the name of the primary function. The primary function name must be different from the replicate function name specified in the with replicate function named clause.

'func_name'

The name of the function, with a maximum length of 255 characters.

with replicate function named

Specifies the name of the stored procedure to execute at the replicate database. If you do not specify a replicate function name, Replication Server uses the replication definition name as the name of the replicate function. The replicate function name must be different from the primary function name specified in the with primary function named clause.

NoteThe primary stored procedure refers to the stored procedure originally invoked by the client, while the replicate stored procedure refers to the stored procedure replicated from the primary database and invoked by the replicate Replication Server.

This request function behavior is different from the request function behavior in Replication Server 15.0.1 and earlier. For more information about the behavior of request function in Replication Server 15.0.1 and earlier versions, see the Replication Server Administration Guide Volume 2.

@param_name

A parameter name from the function. A parameter name cannot appear more than once in each clause in which it appears. You are not required to include parameters and their datatypes, but you must include a pair of parentheses, whether or not you include any parameters.

datatype

The datatype of a parameter in the function. See “Datatypes” for a list of the datatypes and their syntax. Adaptive Server stored procedures and function replication definitions cannot contain parameters with the text, unitext, rawobject, and image datatypes.

searchable parameters

Specifies a list of parameters that can be used in where clauses of define subscription, create subscription, or create article. You must include the parentheses ( ) if you include this clause.

send standby

In a warm standby application, specifies whether to send to the standby database, all the parameters in the function (send standby all parameters) or just those specified in the replication definition (send standby replication definition parameters). The default is send standby all parameters.

Examples

Example 1

Creates a request function replication definition named titles_frep for a function named upd_titles_prim. The stored procedure to be invoked in the destination database is named upd_titles:

create request function replication definition titles_frep
with primary at LDS.pubs2
with primary function named 'upd_titles_prim'
with replicate function named 'upd_titles'
(@title_id varchar(6), @title varchar(80), @type char(12), @pub_id char(4),
     @price money, @advance money, @total_sales int)
searchable parameters (@title_id, @title)

Usage


User-defined functions and function strings


with primary at clause

Use the with primary at clause to specify the primary data server and database. The primary database is the database that contains the invoked primary stored procedure.


with replicate function named clause

Use the with replicate function named clause to specify the name of the stored procedure you want to execute at the destination database where you are delivering the replicated function. If you do not use with replicate function named when you create or alter the function replication definition, the function is delivered as a stored procedure with the same name as the function replication definition. In a warm standby database, the stored procedure has the same name as in the active database so with replicate function named is ignored.

A round-trip replication enables a database to send a data change request to another database and to replicate the data change back to the requesting database. See the Replication Server Administration Guide Volume 1 for more information about how to set up a round-trip replication with both applied and request function replication definitions.


Request function replication definitions for HDS parameters

Although you cannot create function replication definitions that alter the datatype of a parameter’s value, you can use HDS datatype definitions to declare parameters for request function replication definitions. The declared parameters are subjected to class-level translations.

See the Replication Server Administration Guide Volume 1 for more information about HDS.


Altering function replication definitions


Subscribing to function replication definitions

To subscribe to a request function replication definition, use create subscription with the without materialization clause, or use define subscription and the other commands involving bulk materialization.


Creating multiple replication definitions

Permissions

create request function replication definition requires “create object” permission.

See also

alter applied function replication definition, alter function string, alter request function replication definition, create applied function replication definition, create connection, create function string, define subscription, drop function replication definition, sp_setrepproc