Oracle nclob 字段:删除换行(或回车)字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9037354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:34:37  来源:igfitidea点击:

Oracle nclob fields: remove newline (or carriage return) characters

databaseoraclereplacenclob

提问by MrBoJangles

We have information in an Oracle db of type NCLOB, and I want to remove newline characters. This, for example, does not work:

我们在 NCLOB 类型的 Oracle 数据库中有信息,我想删除换行符。例如,这不起作用:

MyNclobCell := REPLACE(MyNclobCell, '\n', '');

Do I have an answer below? Yes, yes I do!

我在下面有答案吗?是的,是的,我愿意!

回答by MrBoJangles

Turns out that I needed to remove both the newline (\n, ascii: 10) and the carriage return (\r, ascii: 13) characters. To use my example above, the one line of code became two as follows:

原来我需要删除换行符 (\n, ascii: 10) 和回车符 (\r, ascii: 13) 字符。以我上面的例子为例,一行代码变成了两行,如下所示:

MyNclobCell := REPLACE(MyNclobCell, chr(10), '');
MyNclobCell := REPLACE(MyNclobCell, chr(13), '');

I then got my NCLOB rows all in a single line, and pasted the contents into a spreadsheet and handed it off to the requestor, hooray!

然后我将我的 NCLOB 行全部放在一行中,并将内容粘贴到电子表格中,然后将其交给请求者,万岁!

Update: As per Saurabh Patil's suggestion, an alternative syntax for code-golfers and single-line-likers:

更新:根据Saurabh Patil的建议,代码高尔夫球手和单线喜欢者的替代语法:

REPLACE(REPLACE(MyNclobCell, chr(10), ''), chr(13), '');