Friday, November 12, 2010

Replacing carriage-returns & line-feeds from a string/column in Oracle/Database.

To replace the carriage-returns & line-feeds from a string in Oracle or database, replace() does not work properly.

There is a special handling required to replace new line or carriage-returns.


If the data in your database is POSTED from HTML form TextArea controls, different browsers use different New Line characters:
  • Firefox separates lines with CHR(10) only
  • Internet Explorer separates lines with CHR(13) + CHR(10)
  • Apple (pre-OSX) separates lines with CHR(13) only
So you may need something like:

  • update table_name set col_name = replace(replace(col_name, CHR(13), ''), CHR(10), '') ;
 

- Cheers!!!

No comments: