I have to remove the last occurrence of a new line character or CHR(13) in the below context .
But the regexp_replace is not doing this.My desired output is in 3rd column , where as the output in column 4 (ENAME_LIST) is actually I m getting.
REGEXP_REPALCE seems to be replacing the last alphabetic instead of the last new line character .
Can you please suggest me as how to modify the below query.
SELECT d.deptno,
d.dname,
REGEXP_REPLACE (XMLAGG (XMLELEMENT (e,
e.ename || CHR(13)
).EXTRACT ('//text()') ORDER BY e.ename).GetClobVal (),'.$') ename_list
FROM dept d LEFT JOIN emp e ON e.deptno = d.deptno
GROUP BY d.deptno, d.dname
ORDER BY d.deptno, d.dname
DEPTNO | DNAME | ENAME_LIST_DESIRED | ENAME_LIST |
---|
10 | ACCOUNTING | CLARK KING MILLER | CLARK KING MILLE |
20 | RESEARCH | ADAMS FORD JONES SCOTT SMITH | ADAMS FORD JONES SCOTT SMIT |
30 | SALES | ALLEN BLAKE JAMES MARTIN TURNER WARD | ALLEN BLAKE JAMES MARTIN TURNER WAR |