Saturday, May 1

How to retrieve Quality center bug details ?

The main table in quality center for defect related info is Bug table. This table stores all the recent /current bug details . There are few columns within this table which would of your interest. Below are columns for reference

BUG.BG_SUMMARY /*Defect.Title*/
BUG.BG_RESPONSIBLE /*Defect.Assigned To*/
BUG.BG_CLOSING_DATE /*Defect.Closing Date*/
BUG.BG_DEV_COMMENTS /*Defect.Comments*/
BUG.BG_DETECTED_BY /*Defect.Detected By*/
BUG.BG_DESCRIPTION /*Defect.Description*/
BUG.BG_BUG_ID /*Defect.ID*/
BUG.BG_USER_32 /*Defect.Defect Status*/
BUG.BG_PRIORITY /*Defect.Priority*/
BUG.BG_PROJECT /*Defect.Project*/
BUG.BG_SEVERITY /*Defect.Severity*/



*Note BUG.BG_USER_32 is defect status in our project which I am using. By default the status of bug is stored in BG_status. So in your project it may be BG_status
There is only one primary key in this table . That is Bg_bug _id which is defect number.
Another table that would be of interest are the audit tables. Audit tables are the ones that store the history of all entities and bug is one of them. So all the historical entries would be stored in audit tables.


So what are these audit tables?

They are two of them . One - AUDIT_LOG , second - AUDIT_PROPERTIES
AUDIT_LOG: This table stores all the actions that any users does on any of QC entities like requirement, bug, test cases or test sets. AU_action ID is the only primary key. Below I have listed the details of each column.

Column NamePkData TypeUse/Description
AU_ACTION_ID1NUMBER (10)This is only primary key and is uniquely generated for every action on QC entities
AU_FATHER_IDNUMBER (10)You can ignore this
AU_USERVARCHAR2 (2000 Char)The user login who is doing the update
AU_SESSION_IDNUMBER (10)Session Id of user
AU_TIMEDATEThe time when the change was done. This one of important field when you are referring to time/date for reopened defect, aging etc
AU_ACTIONVARCHAR2 (200 Char)This details the action whether it is delete or update
AU_ENTITY_TYPEVARCHAR2 (200 Char)This is important field. It will store the name of entity whether it is Bug or requirement etc
AU_ENTITY_IDVARCHAR2 (200 Char)This is important field . It will store the Bug id , test case id etc
AU_DESCRIPTIONCLOBYou can ignore this field for a while




AUDIT_PROPERTIES: This table stores information what is changed to what and from what.


Column NamePkData TypeUse/Description
AP_PROPERTY_ID1NUMBER (10)This is only primary key and is uniquely generate for every action on QC entities
AP_ACTION_IDNUMBER (10)This is a foreign key from Audit Log table
AP_TABLE_NAMEVARCHAR2 (40 Char)This field stores value of QC table like BUG etc, which is been affected by the action
AP_FIELD_NAMEVARCHAR2 (40 Char)This field stores value of which field name that is been changed from the above table
AP_PROPERTY_NAMEVARCHAR2 (50 Char)This field stores the property value that is been affected. Like title , if defect title has been changed etc
AP_OLD_VALUEVARCHAR2 (2000 Char)What was the old value before change
AP_NEW_VALUEVARCHAR2 (2000 Char)what is new value of the entity's property . Like if you change the title to Title 2 from Title 1. Then AP_NEW_VALUE would be Title 2 and AP_OLD_VALUE would be Title 1
AP_OLD_LONG_VALUECLOBYou can ignore this
AP_NEW_LONG_VALUECLOBYou can ignore this
AP_OLD_DATE_VALUEDATEYou can ignore this
AP_NEW_DATE_VALUEDATEYou can ignore this


So what is relationship between these tables?

clip_image002
Let try out first exercise.


To retrieve the list of people to whom all defect had been assigned.

First we will write simple query to retrieve the bug details from bug table. This just returns one row.

Select *
from bug B
where B.bg_bug_id = '1001'

Next lets join audit table AUDIT_LOG


Select Al.AU_ACTION_ID
from bug B , Audit_log AL
where B.Bg_bug_id = '1001'
And Al.AU_entity_id = B.BG_Bug_ID
And AL.AU_entity_type = 'BUG'

The above query would list all the actions that corresponding to Bug 1001.

Next lets join AUDIT_PROPERTIES to retrieve the to whom it all assigned to and when it was assigned

Select Al.AU_time as DateAssigned, AP.AP_NEW_VALUE as Assigned to
from bug B , Audit_log AL
where B.Bg_bug_id = '1001'
And Al.AU_entity_id = B.BG_Bug_ID
And AL.AU_entity_type = 'BUG'
And ap.AP_ACTION_ID = al.AU_ACTION_ID
And AP_FIELD_NAME = 'BG_RESPONSIBLE'

The other useful blogs related to Audit tables and QC history can be found in following locations

  1. First time Fix faliures or Reopen defects
  2. To Extract defects that have undergone severity change
  3. How to retrieve QC status history for closed defect
  4. How to retrieve test instances and test sets within particular folder
  5. How to retrieve requirements and test coverage and linked test cases


16 comments:

  1. hi. nice info thanks for sharing this

    ReplyDelete
  2. You welcome !. More in pipeline for excel reports. keep watching this space.

    ReplyDelete
  3. Thanks!!
    It is of great help

    But could anyone help in writing query for counting Reopen Defects (EXCLUDING defects which are Rejected then Closed)?
    Since "Rejected" Defects needs to change status to "Reopen" while closing a defect

    ReplyDelete
  4. Hi the last part of the QC SQL didn't work for me.

    First it didn't life where the "from" statement appeared, but that was because it was using the "to" in "assigned to" so I just changed that to assignedto.
    next I got an error saying "AP_FIELD_NAME" was an invalid identifier - can't see solution to that one.

    Thanks

    ReplyDelete
  5. Thanks - very usefull as I had to get a report of the amount of entries in the History table for each Bug so this was a life saver.

    ReplyDelete
  6. Thanks Anonymous for visiting my blog- glad that it was life saver.

    ReplyDelete
  7. I was able to get Defect history detail but I need to report how many days it took from New to Open and Open to close status, I am able to do with SQL sub query for one defect(i.e. BG_BUG_ID =100) but not for all the bug by substracting AU_TIME from AP_New_Value, any Idea?
    do you have any example of OTA API?
    thanks in advance!

    ReplyDelete
  8. Hi Shambu,
    I need to extract the "Stage Found" field of the defects. But I couldn't find the back-end field name of "Bug Table.stage found". Please help.

    ReplyDelete
  9. Hi Arun
    I do not remember any field that is standard name of "Stage founc". Best way is to pick a defect and note down the stage found value. Then query the defect table
    "Select * from bug where bug.bug_id = '

    Then look at the column that has the value of "stage found" that you had noted. I guess it is either user defined column and would be like User_32, User_42 etc

    ReplyDelete
  10. Great Blog and Thank you everyone for all the feedback - really appreciate your effort.

    Thanks

    ReplyDelete
  11. Can anyone please help. Unfornately, we are on version 9 that is no longer supported. Our defect history is blank and cannot identify (1) why? (2) how to turn it back on.

    ReplyDelete
  12. As this post is still getting comments 2 years later, it shows how useful people have found it. It is simple, talks in language that people can understand and doesn't assume any level of SQL knowledge.

    Many thanks.

    ReplyDelete
  13. Hi Anonymous
    I presume there seems to be defect in QC 9. Check this KB article that refers to this problem mentioned in SQAforums.com


    HP Software Knowledge Document KM202868 (http://support.openview.hp.com/selfsolve/document/KM202868) KM20868

    ReplyDelete
  14. Thanks Danny for the comment. That is very reassuring. Making me to blog more and very often (which I accept I havent been)

    ReplyDelete
  15. This article was amazing ... Very help full..

    It solved my problem within a 10 mins which i was looking for more than one day ...

    Thanks so Much Shambu.. Excellent post...

    Regards
    Gourish

    ReplyDelete
  16. I need to find, through SQL, if a user-defined field on defects screen is required or not. How do I do that? BUG table shows me my field (BG_User_03, for example) but it does not tell me if this field is required or a history is being maintained on this field, etc. I am sure this information is in one of system tables but I cannot seem figure out where ...

    ReplyDelete

---------------------------------------------

Related Posts Plugin for WordPress, Blogger...