Create Function Strings Examples

Use the examples to create function strings.

rs_begin Function String

Create a function string for the rs_begin function that begins a transaction in the database by executing a stored procedure named begin_xact:
create function string rs_begin
 for gateway_func_class
 output rpc 'execute begin_xact'

rs_insert Function String

Create a function string for a rs_insert function that references the publishers_rep replication definition, which executes an RPC at the replicate database as a result of an insert in the primary table. The stored procedure insert_publisher is defined only at the replicate database.
create function string publishers_rep.rs_insert
    for function class rs_sqlserver_function_class
    output rpc
    'execute insert_publisher
      @pub_id = ?pub_id!new?,
      @pub_name = ?pub_name!new?,
      @city = ?city!new?,
      @state = ?state!new?'

upd_bits Target-Scope Function String

Create a customized function string for the upd_bits stored procedure at the rdb1 target database in the NY_DS data server. Functions for a stored procedure have the same name as the stored procedure.
create function string upd_bits.upd_bits
     for database NY_DS.rdb1
     with overwrite
     output language
     'exec upd_bits
           @firstbit = ?firstbit!param?,
           @secondbit = ?secondbit!param?, 
     @commit = ?comment!param?'