1

尝试在 HP Quality Center 中运行 SQL 查询时收到错误消息。消息是“Quality Center 无法运行查询,因为它包含无效语句。数据库是 Oracle。我的查询是:

WITH AUDIT AS
(
SELECT AUDIT_LOG.AU_ENTITY_ID AS DEFECT_ID,
       MIN(AUDIT_LOG.AU_TIME) AS Date_Deferred,
       AUDIT_LOG.AU_USER AS UserName_Deferred
FROM AUDIT_LOG
INNER JOIN AUDIT_PROPERTIES
ON AUDIT_LOG.AU_ACTION_ID = AUDIT_PROPERTIES.AP_ACTION_ID
WHERE AUDIT_LOG.AU_ENTITY_TYPE = 'BUG' 
  AND AUDIT_LOG.AU_ACTION = 'UPDATE' 
  AND AUDIT_PROPERTIES.AP_TABLE_NAME = 'BUG' 
  AND AUDIT_PROPERTIES.AP_FIELD_NAME = 'BG_STATUS' 
  AND AUDIT_PROPERTIES.AP_NEW_VALUE = 'Deferred'
GROUP BY
    AUDIT_LOG.AU_ENTITY_ID,AUDIT_LOG.AU_USER
),

WITH BUG_LIST AS
(
SELECT BUG.BG_BUG_ID/*Defect.Defect ID*/, BUG.BG_DETECTION_DATE /*Defect.Detected on Date*/,  BUG.BG_USER_01 /*Defect.Application*/, BUG.BG_SEVERITY /*Defect.Severity*/, BUG.BG_STATUS /*Defect.Status*/,  BUG.BG_USER_11 /*Defect.Planned Closing Date*/,  BUG.BG_DETECTED_BY /*Defect.Detected By*/
FROM   BUG /*Defect*/
WHERE  BUG.BG_USER_17 /*Defect.Finding Group*/ = 'UAT'
ORDER BY  BUG.BG_DETECTION_DATE ASC
)

SELECT *
FROM BUG_LIST
INNER JOIN AUDIT ON AUDIT.DEFECT_ID = BUG_LIST.BG_BUG_ID

“AUDIT”查询正在查找 QC 中在某些时候其状态更改为“Deferred”的任何错误。这包含来自所有使用 HPQC 的团队的错误。“BUG_LIST”查询专门查找“UAT”组发现的错误。我可以单独运行每个查询并尝试将两者结合起来,以便获得“UAT”发现的错误列表。如果 UAT 发现的错误具有与其关联的延迟日期状态更改,请显示此信息,如果没有,请将此信息留空以获取特定缺陷。

我之所以尝试这样做是因为任何进入“延期”状态的错误都没有像已关闭错误那样的“计划结束日期”。正因为如此,而不是结束日期,我希望看到错误进入延期状态的日期,并认为这是我的“结束日期”。

HPQC 不支持“WITH”语句吗?有什么方法可以成功组合并运行这些查询吗?

4

2 回答 2

1

你只需要with出现一次,所以去掉with之前的BUG_LIST:

   WITH AUDIT AS
(
SELECT
AUDIT_LOG.AU_ENTITY_ID AS DEFECT_ID,
MIN(AUDIT_LOG.AU_TIME) AS Date_Deferred,
AUDIT_LOG.AU_USER AS UserName_Deferred
FROM AUDIT_LOG
INNER JOIN AUDIT_PROPERTIES
ON AUDIT_LOG.AU_ACTION_ID = AUDIT_PROPERTIES.AP_ACTION_ID
WHERE AUDIT_LOG.AU_ENTITY_TYPE = 'BUG' AND AUDIT_LOG.AU_ACTION = 'UPDATE' AND AUDIT_PROPERTIES.AP_TABLE_NAME = 'BUG' AND AUDIT_PROPERTIES.AP_FIELD_NAME = 'BG_STATUS' AND AUDIT_PROPERTIES.AP_NEW_VALUE = 'Deferred'
GROUP BY
AUDIT_LOG.AU_ENTITY_ID,AUDIT_LOG.AU_USER
),

    BUG_LIST AS
(
SELECT BUG.BG_BUG_ID/*Defect.Defect ID*/, BUG.BG_DETECTION_DATE /*Defect.Detected on Date*/,  BUG.BG_USER_01 /*Defect.Application*/, BUG.BG_SEVERITY /*Defect.Severity*/, BUG.BG_STATUS /*Defect.Status*/,  BUG.BG_USER_11 /*Defect.Planned Closing Date*/,  BUG.BG_DETECTED_BY /*Defect.Detected By*/
FROM   BUG /*Defect*/
WHERE  BUG.BG_USER_17 /*Defect.Finding Group*/ = 'UAT'
ORDER BY  BUG.BG_DETECTION_DATE ASC
)

SELECT *
FROM BUG_LIST
INNER JOIN AUDIT ON AUDIT.DEFECT_ID = BUG_LIST.BG_BUG_ID

您始终可以使用子查询将它们组合成一个from语句:

select *
from (your bug_list query here) bl inner join
     (your audit query here) a
     on a.defect_id = bl.bd_bug_id
于 2012-12-05T21:20:47.087 回答
0

WITH通常用于允许您重用其中一个with 子句。在这种情况下,不需要它,因此可以像这样重写查询。(我无法对此进行测试)

SELECT audit.*, bug_list.*
FROM 
(
    SELECT BUG.BG_BUG_ID/*Defect.Defect ID*/, 
           BUG.BG_DETECTION_DATE /*Defect.Detected on Date*/,  
           BUG.BG_USER_01 /*Defect.Application*/, 
           BUG.BG_SEVERITY /*Defect.Severity*/, 
           BUG.BG_STATUS /*Defect.Status*/,  
           BUG.BG_USER_11 /*Defect.Planned Closing Date*/,  
           BUG.BG_DETECTED_BY /*Defect.Detected By*/
    FROM   BUG /*Defect*/
    WHERE  BUG.BG_USER_17 /*Defect.Finding Group*/ = 'UAT'
) BUG_LIST,
(
    SELECT AUDIT_LOG.AU_ENTITY_ID AS DEFECT_ID,
           MIN(AUDIT_LOG.AU_TIME) AS Date_Deferred,
           AUDIT_LOG.AU_USER AS UserName_Deferred
    FROM AUDIT_LOG
    INNER JOIN AUDIT_PROPERTIES
    ON AUDIT_LOG.AU_ACTION_ID = AUDIT_PROPERTIES.AP_ACTION_ID
    WHERE AUDIT_LOG.AU_ENTITY_TYPE = 'BUG' 
      AND AUDIT_LOG.AU_ACTION = 'UPDATE' 
      AND AUDIT_PROPERTIES.AP_TABLE_NAME = 'BUG' 
      AND AUDIT_PROPERTIES.AP_FIELD_NAME = 'BG_STATUS' 
      AND AUDIT_PROPERTIES.AP_NEW_VALUE = 'Deferred'
    GROUP BY
        AUDIT_LOG.AU_ENTITY_ID,AUDIT_LOG.AU_USER
) AUDIT
INNER JOIN AUDIT 
ON AUDIT.DEFECT_ID = BUG_LIST.BG_BUG_ID
ORDER BY  BUG_list.BG_DETECTION_DATE ASC
于 2012-12-05T22:01:04.940 回答