IBM Support

How to write a Perl script to get database properties of all associated databases with a Schema Repository in Rational ClearQuest

Question & Answer


Question

How do you write a Perl script to get database properties of all the associated databases with a Schema Repository in IBM Rational ClearQuest?

Cause

You would like to use Perl Script code to automate the manual task to be performed to get information on database properties for all the associated databases with a Schema Repository.

Answer

In order to get database properties of all associated databases with a Schema Repository in Rational ClearQuest you can use the Perl Script below:

Note: The ClearQuest must be installed on this machine. and there must be at least one valid Schema Repository in ClearQuest Maintenance tool.

Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.



PROCEDURE:

  1. Navigate to the location where CQperl.exe is installed

    By default it is  C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

  2. Edit a Notepad file to add the below script. Save the file 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", "<AdminPasswd>", "<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";
    $myDb = $dbObj->GetVendor();
    if ($myDb == "1")
    {
    print "My DB Vendor - SQL_SERVER \n";
    }
    elsif ($myDb == "2")
    {
    print "My DB Vendor - MS ACCESS\n";
    }
    elsif ($myDb == "4")
    {
    print "My DB Vendor - Oracle\n";
    }
    elsif ($myDb == "5")
    {
    print "My DB Vendor - DB2\n";
    }
    $myDbname = $dbObj->GetDatabaseName();
    print "My DB Name is -> $myDbname\n";

    $myDbservername = $dbObj->GetServer();
    print "My DB Server name -> $myDbservername\n";

    $myDbloginname = $dbObj->GetDBOLogin();
    print "My DB login name -> $myDbloginname\n";
    print "\n\n\n";
    }
    CQAdminSession::Unbuild($adminSession);
    ******************************************


  3. Execute the script as >cqperl <filename>.pl

Internal Use Only

No

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

Document Information

Modified date:
16 June 2018

UID

swg21669620