RTRIM(CLOB field) in Oracle PL/SQL -
please suppose have clob field in oracle table, in have stored creation script of package/procedure/function.
i remove blanks at end of every line, but:
a) dbms_lob.trim (clob field) procedure , not function; b) rtrim (clob) don't fail, not work achieve this.
how can solve problem?
please note spaces @ beginning of every line useful indentation of pl/sql source code stored in clob field, haven't removed.
thank in advance kind , cooperation.
to remove spaces @ end of each line use regexp_replace()
regular expression function:
regexp_replace(col, '\s+('||chr(10)||'|$)', chr(10))
here example(note: replace
function used highlight spaces):
with t1(col) as( select to_clob('begin '||chr(10)||chr(32)||chr(32)||'something going on here'||chr(32)||chr(32)||chr(10)|| 'end'||chr(32)||chr(32)) dual ) select replace(col, ' ', '_') with_spaces , replace( regexp_replace(col, '\s+('||chr(10)||'|$)', chr(10)) , ' ' , '_' ) without_spaces t1
result:
with_spaces without_spaces --------------------------------------------------------------------- begin__ begin __something_is_going_on_here__ __something_is_going_on_here end__ end
Comments
Post a Comment