Using SQL or PL/SQL to replace empty lines before start of content in CLOB

帅比萌擦擦* 提交于 2019-12-11 19:59:27

问题


If i have a clob field that contains the following text

Note - The @ character denotes an empty line (with or without spaces).

@
@
AB DF SDF DFDS F
FDSFSDF
@
DFSFDSFSDF
@
DSFDS
@
FDSF
DSFS
DF
@
@
@
@

How can i modify it so that all the empty lines at the beginning of the text are removed (i.e. all empty lines up to the first line where there is content)

I know there are several functions that Oracle provide for replacing strings but i am struggling to use any of them when i can ignore the empty lines between the text and the ones at the end of the text. The output should be as shown below.

AB DF SDF DFDS F
FDSFSDF
@
DFSFDSFSDF
@
DSFDS
@
FDSF
DSFS
DF
@
@
@
@

回答1:


You should be able to use the LTRIM function for this:

SELECT LTRIM (clob_field, CHR (10) || CHR (13) || ' ') FROM yourtable;

It doesn't matter what order the characters to be trimmed are in. The only caveat is that this will also remove any leading spaces from the front of the first non-blank line.



来源:https://stackoverflow.com/questions/25693113/using-sql-or-pl-sql-to-replace-empty-lines-before-start-of-content-in-clob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!