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

MrB*_*les 2 database oracle replace nclob

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

MyNclobCell := REPLACE(MyNclobCell, '\n', '');
Run Code Online (Sandbox Code Playgroud)

我在下面有答案吗?是的,是的我做到了!

MrB*_*les 7

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

MyNclobCell := REPLACE(MyNclobCell, chr(10), '');
MyNclobCell := REPLACE(MyNclobCell, chr(13), '');
Run Code Online (Sandbox Code Playgroud)

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

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

REPLACE(REPLACE(MyNclobCell, chr(10), ''), chr(13), '');
Run Code Online (Sandbox Code Playgroud)

  • 要在查询中使用它,您可以将其编写为:REPLACE(REPLACE(MyNclobCell,chr(10),''),chr(13),''); (2认同)
  • @Jangles感谢您的回复,我得到了这个问题的解决方案,下面的代码有效 REGEXP_REPLACE(REPLACE(REPLACE(NOTES, CHR(10), ';'), CHR(13), ';'), '(;){ 2,}', ';')) (2认同)