Request functions

Use a request function to deliver a replicated stored procedure from a replicate database to the primary database. For example, a client application at a remote location needs to make changes to primary data. The client application first executes a stored procedure at the replicate site—a procedure that may or may not make changes at the replicate database. When the stored procedure executes, the replicate Replication Server passes a request function to the primary, where a corresponding stored procedure is invoked that updates the primary data.

With a primary copy model, a single primary database contains all the latest updates. A client application at a remote site can update the primary using request functions. As updates occur at the primary table, Replication Server captures the updates and sends them to replicate data servers.

If communication between the primary and destination databases fails, operations executed in the primary database are stored in Replication Server stable queues until they can be delivered to replicate sites. Likewise, operations executed remotely are held in stable queues until they can be delivered to the primary database.

To use a request function, create a stored procedure in the primary database and a corresponding stored procedure in the replicate database. Then, at a primary Replication Server, create a function replication definition. You do not need to create any subscriptions. When the stored procedure in the replicate database is invoked, it, in turn, invokes the stored procedure in the primary database.

Replication Server executes the stored procedure in the primary database as the user who executed the stored procedure in the replicate database. This guarantees that only authorized users can change primary data.

In an application, Replication Server may replicate some or all of the data that is changed in the primary database. The changes are distributed to replicate databases managed by Replication Servers that have subscriptions to table replication definitions or as separate applied functions. Either way, the effect of a transaction arrives at the primary and then replicate databases.

When you use request functions, all updates are made at the primary database. This preserves Replication Server’s primary copy data model and protects the replication system from network failure and excess traffic.