Skip to main content
WolfShade
Legend
April 25, 2018
Answered

Oracle 11g: keeping "new line" / "line breaks" in a varchar2(4000) column?

  • April 25, 2018
  • 1 reply
  • 1004 views

Hello, all,

What is the best way to preserve line breaks from a <textarea> when inserting into an Oracle varchar2(4000) column?

I'm creating a comments section for a blog, and want to keep the input as the user entered it.

This is being processed in ColdFusion 10/11.

V/r,

^ _ ^

CORRECTION:  Apparently, the line breaks are being kept, just fine, when I "view source" the page.  So, this is a formatting-after-get issue, not an Oracle issue.  Nevermind. 

This topic has been closed for replies.
Correct answer WolfShade

Fixed it.  Not the best solution, but..

<div>

<p>#REreplaceNoCase(comment_text,"[\r|\n|#chr(13)#|#chr(10)#]","</p><p>","all")#</p>

</div>

Keeps formatting, although the space between lines is larger than I'd like.

V/r,

^ _ ^

1 reply

WolfShade
WolfShadeAuthorCorrect answer
Legend
April 25, 2018

Fixed it.  Not the best solution, but..

<div>

<p>#REreplaceNoCase(comment_text,"[\r|\n|#chr(13)#|#chr(10)#]","</p><p>","all")#</p>

</div>

Keeps formatting, although the space between lines is larger than I'd like.

V/r,

^ _ ^