GetLocalReplica

Description

Gets replication information and returns an information object.

If your current HCL Compass release supports HCL Compass MultiSite, then this method returns an Entity object of type ratl_replicas.

You can use the returned object to determine whether your local HCL Compass database has been replicated with HCL Compass MultiSite. You can also use this method to find information about current replication, such as the names and locations of replica databases.

The Replica object that this method returns is like any Entity object returned by the GetEntity method on the Session object. This means that you can use any of the methods associated with an Entity object to query the Replica object.

Syntax

VBScript


set replicaObj = session.GetLocalReplica

Perl


$replicaObj = session->GetLocalReplica();
Identifier
Description
session
The Session object that represents the current database-access session.
Return value
The "ratl_replicas" Entity object associated with the current session or NULL if the current database has not been updated for HCL Compass MultiSite.

You can create a query against the "ratl_replicas" Entity (which contains the list of replicas known to this database) and compare the "Name" field against replicaName (see example following) to determine if the information applies to the local database or one of the other replicas. Or you can compare the "Host" field to localReplicaHost to determine how you might have to communicate with other programs dealing with the particular replica. For example, if the replica is not local, you might have to use e-mail.

Example

VBScript


set session = GetSession

set replicaObj = session.GetLocalReplica

fieldNameList = replicaObj.GetFieldNames



For Each fieldName in fieldNameList

    set fieldInfoObj = GetFieldValue(fieldName)

    fieldType = fieldInfoObj.GetType

    fieldValue = fieldInfoObj.GetValue

    If fieldName = "Name" Then  'replica db name

        If fieldValue = "<local>" Then

            'Database has not been replicated

        else

            localReplicaName = fieldValue

        End If

    ElseIf fieldName = "Host" Then 'db host name

        'host name of replica database:

        replicaHost = fieldValue

    End If

Next
Perl
use CQPerlExt;



my $sess;

my $entity;



$sess = CQSession::Build();

$sess->UserLogon("admin", "", "MULTI", "CQMS.MS_ACCESS.SITEA");



if ($sess->IsReplicated()) {

   # print out the local replica name

    $entity = $sess->GetLocalReplica();

    printf "Local replica is %s.\n", $entity->GetDisplayName();

}

CQSession::Unbuild($sess);