Mapping to a different stored procedure name

When you create a user-defined function in a database that uses the a function-string class for which default generated function strings are provided, Replication Server generates a default function string. The default generated function string executes a stored procedure with the same name and parameters as the user-defined function.

For example, if you are using a default function string, you can set up a request stored procedure to execute in the replicate database by creating a stored procedure in the primary database with the same name and parameters as the user-defined function.

If you want to map the user-defined function to a different stored procedure name, use the alter function string command to configure Replication Server to deliver the stored procedure by executing a stored procedure with a different name. You can also do so in function-string classes that allow you to customize function strings.

Example

This example illustrates how to map a user-defined function to a different stored procedure name.

  1. Assume the stored procedure upd_sales exists on the primary Adaptive Server, and that it performs an update on the Adaptive Server sales table:

    create proc upd_sales
     @stor_id varchar(10),
     @ord_num varchar(10),
     @date datetime
     as
    64 update sales set date = @date
     where stor_id = @stor_id
     and ord_num = @ord_num
    
  2. To register the upd_sales stored procedure with the Replication Server, create the following function, whose name includes in its name the sales_def replication definition on the sales table and the upd_sales replicated stored procedure:

    create function sales_def.upd_sales
     (@stor_id varchar(10), @date datetime)
    
  3. On the replicate Adaptive Server, a version of the stored procedure upd_sales that performs no work is created with the same name:

    create proc upd_sales
     @stor_id varchar(10),
     @ord_num varchar(10),
     @date datetime
     as
     print "Attempting to Update Sales Table"
     print "Processing Update Asynchronously"
    
  4. To execute the upd_sales stored procedure with the name real_update instead of upd_sales:

    • The default generated function string is altered:

      alter function string sales_def.upd_sales
       for rs_sqlserver_function_class
       output rpc
       'execute real_update
       @stor_id = ?stor_id!param?,
       @date = ?date!param?'
      
    • A stored procedure in the primary database is created with the name real_update. It accepts two parameters.