在CLOB中开始内容之前,使用SQL或PL/SQL替换空行 [英] Using SQL or PL/SQL to replace empty lines before start of content in CLOB
问题描述
如果我的Clob字段包含以下文本
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)
我知道Oracle提供了一些用于替换字符串的函数,但是当我可以忽略文本和文本结尾之间的空行时,我正努力使用其中的任何一个.输出应如下所示.
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
@
@
@
@
推荐答案
您应该能够为此使用LTRIM
函数:
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.
这篇关于在CLOB中开始内容之前,使用SQL或PL/SQL替换空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!