Monday, October 25, 2010

Remove tags from comment field

Use REGEXP_REPLACE(X.COMMENTS,'<[^<>]*>','') to remove tags like below:

SELECT
A.HRS_JOB_OPENING_ID,
A.CLOSE_DT,
A.STATUS_REASON,
,X.COMMENTS
,REGEXP_REPLACE(X.COMMENTS,'<[^<>]*>','')
FROM PS_HRS_JOB_OPENING A, PS_HRS_OPNAPR_XREF X
WHERE A.HRS_JOB_OPENING_ID = X.HRS_JOB_OPENING_ID
AND A.STATUS_REASON <> ''

In addition, you could explore these two functions:
1) htf.escape_sc(x.comments)
2) dbms_xmlgen.convert(x.comments)