IBM Support

How to find all the Defects which have 1-Critical severity and still in Submitted state using Rational ClearQuest APIs and SQL query

Technote (FAQ)


How do you find all the Defects which have "1-Critical" severity and still in "Submitted" state using IBM Rational ClearQuest APIs and SQL query?


You need to get an instant and brief report on the Defects which have 1-Critical severity and still in Submitted state without logging into IBM Rational ClearQuest Client.


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

Note: The ClearQuest Native Client must be installed on this machine.

This script iterates through all the ClearQuest Defects to find all the Defects which have 1-Critical severity and still in Submitted state. This script will prints Defect ID, State and Severity of the Defect.


  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 and save with a .pl extension.


    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.

    #!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
    my $sessionObj = CQSession::Build();

    # Logon as admin
    # Provide correct values for admin password, User Database, and Schema Repository name
    $sessionObj->UserLogon("admin", "<adminPassword>", "<UserDataBase>", "<SchemaRepository>");

    my $sqlstring = "select distinct T1.dbid,,,T1.severity from Defect T1,statedef T2 where T1.state = and (T1.dbid <> 0 and (( = 'Submitted' and T1.severity = '1-Critical'))) order by ASC";
    my $ResultSet = $sessionObj-> BuildSQLQuery($sqlstring);

    $recordCount = $ResultSet->GetRecordCount();

    print "Total number of defects in Submitted state with severity as 1-Critical are - $recordCount\n";
    for ($i=0;$i<$recordCount;$i++) {
    $status = $ResultSet->MoveNext();

    $ClearQuestID[$i]= $ResultSet->GetColumnValue(2);
    $State[$i] = $ResultSet->GetColumnValue(3);
    $Severity[$i] = $ResultSet->GetColumnValue(4);

    print "ID-$ClearQuestID[$i]  *** State-$State[$i]  *** Severity-$Severity[$i]\n";
    #Unbuild the Admin session

  3. Run the following command

    cqperl <>

Document information

More support for: Rational ClearQuest

Software version:

Operating system(s): Windows

Reference #: 1653184

Modified date: 16 October 2013