Oracle
 sql >> Datenbank >  >> RDS >> Oracle

Wie erstelle ich eine CLOB-Spalte in einer Gruppe nach Ausdruck? Irgendwelche Arbeiten in der Nähe?

Hier ist die Syntax, die Sie möglicherweise für Ihre Anforderung verwenden möchten:

Syntax:

DBMS_LOB.SUBSTR (lob_loc, amount, offset)

Parameter Description 
lob_loc: Locator for the LOB to be read i.e CLOB column name. 
amount: Number of bytes (for BLOBs) or characters (for CLOBs) to be read. 
offset: Offset in bytes (for BLOBs) or characters (for CLOBs) from the start of the LOB (origin: 1). 

Ihre letzte Abfrage sollte also in etwa so lauten:

    SELECT
    Test_Case_Name,
    DBMS_LOB.SUBSTR(Test_Case_Description,2000,1) as Test_Case_Description,
    Test_Case_Status,
CASE WHEN Test_Case_Status = 'FAILED' THEN
    LISTAGG(LN.LN_BUG_ID,', ') WITHIN GROUP(ORDER BY LN.LN_BUG_ID)
END AS Defect_ID
FROM Test LEFT JOIN LINK LN ON
    LN.LN_ENTITY_ID=Test.TS_TEST_ID
GROUP BY
    Test_Case_Name,
    Test_Case_Description,
    Test_Case_Status

Da Sie sich Sorgen machen, nach 4000 Zeichen keine Daten zu verlieren, schlage ich vor, die Spalte zu unterteilen und wie folgt anzuzeigen..

SELECT
    Test_Case_Name,
    DBMS_LOB.SUBSTR(Test_Case_Description,4000,1) as Test_Case_Description1,
    DBMS_LOB.SUBSTR(Test_Case_Description,8000,4001) as Test_Case_Description2
    Test_Case_Status,
CASE WHEN Test_Case_Status = 'FAILED' THEN
    LISTAGG(LN.LN_BUG_ID,', ') WITHIN GROUP(ORDER BY LN.LN_BUG_ID)
END AS Defect_ID
FROM Test LEFT JOIN LINK LN ON
    LN.LN_ENTITY_ID=Test.TS_TEST_ID
GROUP BY
    Test_Case_Name,
    Test_Case_Description1,
    Test_Case_Description2,
    Test_Case_Status