在HP Quality Center 9.2數據庫中,我正在對Oracle 10g - 10.2.0.40進行一些查詢。我可以將2列粘貼到resultSet嗎?
我構建了一個查詢,該查詢將轉到由SIGA鍵給出的測試文件夾,只選擇給定測試文件夾內對該發行版具有正確可跟蹤性的測試。
它也有2個計數器子查詢: TOTAL1總和測試文件夾中的測試總數。 TOTAL2以正確的可追溯性返回測試文件夾中的測試總量。
該查詢工作正常,但有一個缺陷:如果文件夾內沒有任何測試與正確的版本相關聯,則結果集返回空,但即使如此,我希望返回TOTAL1和TOTAL2列,像這樣:
|SIGA| |PROJETO| |ORIGEM|........ |TOTAL1| |TOTAL2|
|NULL| |NULL| |NULL| ........ |10| |0|
那麼,事情是:每次共2爲0時,「主」 ResultSet是空的,因爲它應該,但即使強硬。我希望有共1頁和頁共2列。
即使使用空的resultSet,是否可以將TOTAL1和TOTAL2的新列「粘合」到主查詢中?我試圖讓左連接,但沒有工作。
謝謝, Cleber。
SELECT
'@[email protected]' AS SIGA,
CYCL_FOLD.CF_ITEM_NAME AS Projeto,
CYCLE.CY_CYCLE AS Origem,
REQ_NAMES.PROCESSO AS Processo,
REQ_NAMES.FUNCIONALIDADE AS Funcionalidade,
ALL_LISTS.AL_DESCRIPTION AS Cenario,
TEST.TS_TEST_ID AS Test_ID,
TESTCYCL.TC_USER_01 AS ID_Cliente,
TEST.TS_NAME AS Nome_do_Caso,
TESTCYCL.TC_USER_02 AS Dependencia,
TEST.TS_USER_06 AS Tipo_Teste,
TEST.TS_USER_02 AS Tipo_Cenario,
/* Descricao */
REGEXP_REPLACE(CAST(TEST.TS_DESCRIPTION AS VARCHAR2(4000)), '<[^<]+>', NULL) AS Descricao,
/* Pre_Condicao */
REGEXP_REPLACE(CAST(TEST.TS_USER_25 AS VARCHAR2(4000)), '<[^<]+>', NULL) AS Pre_Condicao,
/* Resultado_Esperado */
REGEXP_REPLACE(CAST(TEST.TS_USER_26 AS VARCHAR2(4000)), '<[^<]+>', NULL) AS Resultado_Esperado,
/* Dados_Necessarios */
REGEXP_REPLACE(CAST(TEST.TS_USER_27 AS VARCHAR2(4000)), '<[^<]+>', NULL) AS Dados_Necessarios,
TESTCYCL.TC_USER_04 AS Resp_Execucao,
TESTCYCL.TC_STATUS AS Status,
TEST.TS_USER_03 AS Sistemas_Impactados,
TEST.TS_USER_05 AS Regressão,
TEST.TS_RESPONSIBLE AS Autor_Do_Caso,
/* Comentario */
REGEXP_REPLACE(CAST(TEST.TS_DEV_COMMENTS AS VARCHAR2(4000)) , '<[^<]+>', NULL)AS Comentario,
TOTAL1.Total_Testes_TestFolder,
TOTAL2.Total_Testes_Com_Rastr
FROM
(
SELECT
COUNT(TESTCYCL.TC_TEST_ID) AS Total_Testes_TestFolder
FROM
CYCLE,
CYCL_FOLD,
TESTCYCL
WHERE
TESTCYCL.TC_CYCLE_ID = CYCLE.CY_CYCLE_ID
AND CYCLE.CY_FOLDER_ID = CYCL_FOLD.CF_ITEM_ID
AND CYCL_FOLD.CF_ITEM_NAME LIKE CONCAT('@[email protected]','%')
)
TOTAL1,
(
SELECT
COUNT(DISTINCT CONCAT(TESTCYCL.TC_TESTCYCL_ID, TESTCYCL.TC_TEST_ID)) AS
Total_Testes_Com_Rastr
FROM
CYCL_FOLD,
CYCLE,
TESTCYCL,
REQ_COVER,
REQ_CYCLES,
RELEASE_CYCLES
WHERE
TESTCYCL.TC_CYCLE_ID = CYCLE.CY_CYCLE_ID
AND cycle.CY_FOLDER_ID = CYCL_FOLD.CF_ITEM_ID
AND CYCL_FOLD.CF_ITEM_NAME LIKE CONCAT('@[email protected]','%')
AND REQ_COVER.RC_ENTITY_ID = TESTCYCL.TC_TEST_ID
AND REQ_COVER.RC_REQ_ID = REQ_CYCLES.RQC_REQ_ID
AND REQ_CYCLES.RQC_CYCLE_ID = RELEASE_CYCLES.RCYC_ID
AND RELEASE_CYCLES.RCYC_NAME LIKE CONCAT('@[email protected]','%')
ORDER BY
TESTCYCL.TC_TEST_ID
)
TOTAL2,
CYCL_FOLD
LEFT JOIN RELEASE_CYCLES
ON
RELEASE_CYCLES.RCYC_ID = CYCL_FOLD.CF_ASSIGN_RCYC
LEFT JOIN CYCLE
ON
CYCLE.CY_FOLDER_ID = CYCL_FOLD.CF_ITEM_ID
LEFT JOIN TESTCYCL
ON
TESTCYCL.TC_CYCLE_ID = CYCLE.CY_CYCLE_ID
LEFT JOIN TEST
ON
TEST.TS_TEST_ID = TESTCYCL.TC_TEST_ID
LEFT JOIN ALL_LISTS
ON
ALL_LISTS.AL_ITEM_ID = TEST.TS_SUBJECT
INNER JOIN
(
SELECT
TESTCYCL.TC_TEST_ID AS TEST_ID,
wm_concat(REQ2.RQ_REQ_NAME) AS Processo,
wm_concat(REQ1.RQ_REQ_NAME) AS Funcionalidade
FROM
CYCL_FOLD
LEFT JOIN CYCLE
ON
CY_FOLDER_ID = CYCL_FOLD.CF_ITEM_ID
RIGHT JOIN TESTCYCL
ON
TC_CYCLE_ID = CYCLE.CY_CYCLE_ID
RIGHT JOIN REQ_COVER
ON
RC_ENTITY_ID = TESTCYCL.TC_TEST_ID
INNER JOIN REQ REQ1
ON
RC_REQ_ID = REQ1.RQ_REQ_ID
INNER JOIN REQ REQ2
ON
REQ1.RQ_FATHER_ID = REQ2.RQ_REQ_ID
INNER JOIN REQ_TYPE
ON
REQ2.RQ_TYPE_ID = REQ_TYPE.TPR_TYPE_ID
AND REQ_TYPE.TPR_NAME = 'Processo'
RIGHT JOIN REQ_CYCLES
ON
RQC_REQ_ID = REQ1.RQ_REQ_ID
INNER JOIN RELEASE_CYCLES
ON
RQC_CYCLE_ID = RELEASE_CYCLES.RCYC_ID
AND CF_ASSIGN_RCYC = RELEASE_CYCLES.RCYC_ID
WHERE
CF_ITEM_NAME LIKE CONCAT('@[email protected]','%')
GROUP BY
TESTCYCL.TC_TEST_ID
UNION
SELECT
TESTCYCL.TC_TEST_ID AS TEST_ID,
'' AS Processo,
wm_concat(REQ1.RQ_REQ_NAME) AS Funcionalidade
FROM
CYCL_FOLD
LEFT JOIN CYCLE
ON
CY_FOLDER_ID = CYCL_FOLD.CF_ITEM_ID
RIGHT JOIN TESTCYCL
ON
TC_CYCLE_ID = CYCLE.CY_CYCLE_ID
RIGHT JOIN REQ_COVER
ON
RC_ENTITY_ID = TESTCYCL.TC_TEST_ID
INNER JOIN REQ REQ1
ON
RC_REQ_ID = REQ1.RQ_REQ_ID
INNER JOIN REQ REQ2
ON
REQ1.RQ_FATHER_ID = REQ2.RQ_REQ_ID
INNER JOIN REQ_TYPE
ON
REQ2.RQ_TYPE_ID = REQ_TYPE.TPR_TYPE_ID
AND REQ_TYPE.TPR_NAME <> 'Processo'
RIGHT JOIN REQ_CYCLES
ON
RQC_REQ_ID = REQ1.RQ_REQ_ID
INNER JOIN RELEASE_CYCLES
ON
RQC_CYCLE_ID = RELEASE_CYCLES.RCYC_ID
AND CF_ASSIGN_RCYC = RELEASE_CYCLES.RCYC_ID
WHERE
CF_ITEM_NAME LIKE CONCAT('@[email protected]','%')
GROUP BY
TESTCYCL.TC_TEST_ID
)
REQ_NAMES
ON
REQ_NAMES.TEST_ID = TEST.TS_TEST_ID
WHERE
CYCL_FOLD.CF_ITEM_NAME LIKE CONCAT('@[email protected]','%')
ORDER BY
CYCLE.CY_CYCLE,
ALL_LISTS.AL_DESCRIPTION,
REQ_NAMES.PROCESSO,
TEST.TS_TEST_ID
我覺得上面的查詢替換爲屬於thedailywtf.com .... – Chandu 2011-04-13 02:37:54
我的一個朋友說,他將它發送到那裏,我不知道網站,可能已經=) 今天我發現了一個更好的方法來做到這一點: 'REGEXP_REPLACE(CAST(TEST.TS_DESCRIPTION AS VARCHAR2(4000)),'<[^<]+>',NULL)AS Descricao,' – cbaldan 2011-04-13 13:09:23
thedaily wtf ...大聲笑 – tbone 2011-04-13 14:29:17