Skip to content
Advertisement

oracle: remove only blank lines

How to remove empty lines in sql or plsql Input

Expected output:

TRANSLATE is removing all the new line character

Advertisement

Answer

You can do it in one regexp_replace. Specify the arguments for multiline mode and just replace zero or more whitespace characters at the start of the line with nothing. This way only spaces at the start of the lines, if any, are removed so embedded spaces (maybe between words) are preserved, if that’s what you want.

Output:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement