Name

repl_status — returns status of a published or subscribed publication

Synopsis

repl_status ( in publisher varchar ,
  in publication varchar ,
  out level integer ,
  out stat integer );
 

Description

Given a publisher and publication name this returns the status of the publication on the local server.

Parameters

publisher

Name of the publisher.

publication

Name of the publication.

level

If the publisher is the name of the local server this returns the next transaction number to be assigned to a transaction as the level output parameter.

If the publisher is other than the local server this returns the transaction number of the last transaction of that publication that has successfully been replicated to the local database as the level output parameter.

stat

The stat output parameter reflects the current state of the subscription. If the publisher is the local server the stat is always 0. Otherwise it has the following possible values:

0 - off The subscription exists but there is no present or past activity..
1 - syncing - A sync has successfully been requested and transactions are coming from the publisher at the present time.
2 - in sync - The syncing phase has terminated and and this server is in sync with the publisher. This does not mean all the publisher's published transactions have at all times been replayed but this does mean that the sync request reached the end of the replication transaction log and that the servers were in sync at that moment.
3 - disconnected by remote - The remote has disconnected this subscriber. This may be for various reasons, including that this subscriber has fallen too far behind in replaying the published transaction and has thus fallen out of sync. This state means that a resync can be retried with the repl_sync() function.
4 - disconnected locally - This state is set for forward (publisher to subscriber) accounts when the corresponding pushback account is disconnected because of replication queue overflow. This state means that a resync can be retried with the repl_sync() function.
5 - waiting for local disconnect - Local disconnect is about to happen for this account. This state is set for forward (publisher to subscriber) accounts when corresponding pushback account is disconnected because of replication queue overflow. This state means that "disconnected locally" state will be set for this account when next replication message for this account arrives. This state means that a resync can be retried with the repl_sync() function.

Example

Example 24.332. Retrieving the subscription status

This example shows an analogue of the REPL_STAT() function.

create procedure MY_REPL_STAT ()
{
  declare server, account, status varchar;
  declare level, stat integer;
  status := vector ('OFF', 'SYNCING', 'IN SYNC', 'REMOTE DISCONNECTED', 'DISCONNECTED', 'TO DISCONNECT');
  result_names (server, account, level, stat);
  for select SERVER, ACCOUNT from DB.DBA.SYS_REPL_ACCOUNTS do
    {
      repl_status (SERVER, ACCOUNT, level, stat);
        result (SERVER, ACCOUNT, level, aref (status, stat));
    }
};