Show TOC

rs_commitLocate this document in the navigation structure

Commits a transaction in a data server.

Examples
Example 1

This example illustrates the default rs_commit function string for the <rs_sqlserver_function_class> and <rs_default_function_class> classes. The function string executes a stored procedure named rs_update_lastcommit and then executes the Transact-SQL commit transaction command.

create function string rs_commit
 for sqlserver_derived_class
 output language
 'execute rs_update_lastcommit
   @origin = ?rs_origin!sys?,
   @origin_qid = ?rs_origin_qid!sys?,
   @secondary_qid = ?rs_secondary_qid!sys?,
   @origin_time = ?rs_origin_commit_time!sys?;
 commit transaction'
Here is the text of the rs_update_lastcommit procedure for <rs_sqlserver_function_class>:
/* Create a procedure to update the 
 ** rs_lastcommit table. */
 create procedure rs_update_lastcommit
     @origin  int,
     @origin_qid  binary(36),
     @secondary_qid  binary(36),
     @origin_time  datetime
 as
 begin
     update rs_lastcommit
         set origin_qid = @origin_qid,
         secondary_qid = @secondary_qid,
         origin_time = @origin_time, 
         commit_time = getdate()
     where origin = @origin
     if (@@rowcount = 0)
     begin
         insert rs_lastcommit (origin, 
             origin_qid, secondary_qid,
             origin_time, commit_time,
             pad1, pad2, pad3, pad4, 
             pad5, pad6, pad7, pad8)
             values (@origin, @origin_qid,
             @secondary_qid,@origin_time,
             getdate(), 0x00, 0x00, 0x00,
             0x00, 0x00, 0x00, 0x00, 0x00)
     end
 end
Usage
  • The rs_commit function has function-string-class scope.

  • Replication Server creates an initial rs_commit function string for the system-provided function-string classes during installation.

  • If you use a user-created base function-string class, you must create an rs_commit function string.

  • Create or customize an rs_commit function string at the Replication Server that is the primary site for the class.

  • Update the <rs_lastcommit> system table in the rs_commit function string. Updating this table within the transaction maintains data integrity.

Caution

If the <rs_lastcommit> system table is not updated properly for each transaction committed, after a restart Replication Server may apply transactions more than once or skip transactions.