IBM Support

How to find out databases names attached to a Schema Repository using a Perl script in IBM Rational ClearQuest

Question & Answer


Question

How do you find out databases names attached to a Schema Repository using a Perl script in IBM Rational ClearQuest?

Cause

You would want to find out names of the databases attached to a Schema Repository using Perl script and IBM Rational ClearQuest APIs; without using ClearQuest Designer.

Answer

The Perl Script below uses the ClearQuest API and can be run on Windows.

This script iterates through all the Databases in the provided Schema Repository and prints the name on command prompt.

Prerequisites:

The ClearQuest Client must be installed on this machine.

Procedure:

  1. Navigate to the location where CQperl.exe is installed.
    By default: C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

  2. Save the following Perl script text to notepad with a .pl extension.

    ***************************************************************
    #!C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe
    # Make sure you have correct path for CQperl.exe

    use CQPerlExt;

    # Create a Rational ClearQuest admin session
    $adminSession= CQAdminSession::Build();

    # Logon as admin
    # Provide correct login details
    $adminSession->Logon( "admin", "<AdminPassword>", "<SchemaRepositoryName>" );
    $dbList = $adminSession->GetDatabases();

    # Get the number of databases $numDbs = $dbList->Count();

    # Iterate through the databases
    for ( $x=0; $x<$numDbs; $x++ )
    {
    $dbObj = $dbList->Item( $x );$dbName = $dbObj->GetName();
    print "DB is $dbName\n";
    }
    CQAdminSession::Unbuild($adminSession);
    ***************************************************************

  3. Run this script as
> cqperl <filename>.pl

[{"Product":{"code":"SSSH5A","label":"Rational ClearQuest"},"Business Unit":{"code":"BU004","label":"Hybrid Cloud"},"Component":"API","Platform":[{"code":"PF033","label":"Windows"}],"Version":"8.0.1","Edition":""}]

Document Information

Modified date:
16 June 2018

UID

swg21666302