Как удалить / заменить "sys.DBMSOUTPUT_LINESARRAY" в наборе результатов в Oracle? - PullRequest
0 голосов
/ 15 октября 2018

Я построил этот запрос -

SELECT Trim(owner_dsply_nm)                  AS CASE_OWNER 
           ,count(distinct case_intrl_id)        AS NUMBER_OF_CASES_WORKED
           ,cast(collect(distinct case_intrl_id) AS sys.DBMSOUTPUT_LINESARRAY) AS CASE_ID 
           ,Trim(status_nm)                      AS STATUS_VALUE 
           ,To_char(action_ts, 'MON.DD.YYYY')    AS STATUS_CHANGE_DATE 
           ,To_char(action_ts - 7 / 24, 'IYYY')  AS STATUS_CHANGE_YEAR 
           ,To_char(action_ts - 7 / 24, 'IW')    AS STATUS_CHANGE_WEEK 
      FROM KDD_CASE_ACTIONS a 
           join KDD_STATUS s 
             ON a.status_cd = s.status_cd 
           join KDD_REVIEW_OWNER r 
             ON r.owner_seq_id = a.action_by_id 
     WHERE a.status_cd NOT IN ( 'SBTMNEW', 'NW', 'SB01NEW' ) 
     AND Trim(UPPER(owner_dsply_nm)) NOT IN ('SYSTEM')
     GROUP BY Trim(owner_dsply_nm) 
              ,Trim(status_nm) 
              ,To_char(action_ts, 'MON.DD.YYYY') 
              ,To_char(action_ts - 7 / 24, 'IYYY') 
              ,To_char(action_ts - 7 / 24, 'IW') 

Result

Я хочу удалить / скрыть «SYS.DBMSOUTPUT_LINESARRAY» из набора результатов.Что еще можно попробовать в моем запросе?

1 Ответ

0 голосов
/ 16 октября 2018

Я решил ее, заменив sys.DBMSOUTPUT_LINESARRAY на XMLAGG и применив к ней regexp_replace.

SELECT Trim(owner_dsply_nm)                  AS CASE_OWNER 
       ,count(distinct case_intrl_id)        AS NUMBER_OF_CASES_WORKED
       --,cast(collect(distinct case_intrl_id) AS sys.DBMSOUTPUT_LINESARRAY)  AS CASE_ID  
       ,regexp_replace((RTRIM(XMLAGG(XMLELEMENT(E,case_intrl_id,',').EXTRACT('//text()') ORDER BY case_intrl_id).GetClobVal(),',')),'([^,]+)(,\1)+', '\1') AS CASE_ID
       ,Trim(status_nm)                      AS STATUS_VALUE 
       ,To_char(action_ts, 'MON.DD.YYYY')    AS STATUS_CHANGE_DATE 
       ,To_char(action_ts - 7 / 24, 'IYYY')  AS STATUS_CHANGE_YEAR 
       ,To_char(action_ts - 7 / 24, 'IW')    AS STATUS_CHANGE_WEEK 
FROM KDD_CASE_ACTIONS a
       join KDD_STATUS s 
         ON a.status_cd = s.status_cd 
       join KDD_REVIEW_OWNER r 
         ON r.owner_seq_id = a.action_by_id 
 WHERE a.status_cd NOT IN ( 'SBTMNEW', 'NW', 'SB01NEW' ) 
 AND Trim(UPPER(owner_dsply_nm)) NOT IN ('SYSTEM')
 GROUP BY Trim(owner_dsply_nm) 
          ,Trim(status_nm) 
          ,To_char(action_ts, 'MON.DD.YYYY') 
          ,To_char(action_ts - 7 / 24, 'IYYY') 
          ,To_char(action_ts - 7 / 24, 'IW') 
 ORDER BY STATUS_CHANGE_YEAR DESC 
          ,STATUS_CHANGE_WEEK DESC 
          ,CASE_OWNER; 
...