0

I want to remove a line break when selecting a column in an Oracle database.

So far, I have only found

SELECT translate(myCol, chr(10)||chr(13), ' ') from myTable

but that does not return results when making ' ' to ''.

How do I remove the line break and not replace it with another sign?

1
  • 2
    Try to use the replace function. Replace accepts the empty string as parameter: replace(myCol, chr(13) || chr(10), '') Commented Feb 24, 2021 at 10:55

1 Answer 1

1

Pay attention on how translate works: it "translates" single characters, one by one and positionally; for example, this

select translate('abcdefg', 'ac', ' ') from dual

substitutes 'a' with blank and 'c' with nothing, because the second string has nothing in the second position, thus removing 'c'. So, you may need something like:

translate(myCol, 'X' || chr(13) || chr(10), 'X')

This changes 'X' into 'X', chr(13) and chr(10) into nothing, so it just removes chr(10) and chr(13)

Also, notiche that in this way you don't only remove the concatenation of chr(13) and chr(10), but every occurrence of chr(13) and chr(10).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.