Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Does CHR(10) add an extra newline?
On Wed, 21 Nov 2007 12:06:01 -0500, Brian Tkatch <N/A> wrote:
>While writing a query to do some editting i wanted to use CHR(10) to
>have a query do some formatting. It seems that whenever it is used, it
>adds an extra newline at the end of the line.
>
>
>SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual
>CONNECT BY LEVEL < 4)
>
> A B
>---------- -----------------------------------------
> 1
> 1
>
> 2
> 2
>
> 3
> 3
>
>
>3 rows selected.
>
>SQL>
>
>How do i add a newline in middle of a line without adding at the end
>as well?
>
>B.
OK, figured it out. RECSEP by default is set to WRAPPED, so SQL*PLUS detects the CHR(10) as a line wrap and uses RECSEPCHAR which defaults to a space. SETting RECSEP OFF turns this off.
SQL> SET RECSEP OFF
SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual
CONNECT BY LEVEL < 4);
A B
---------- ----------------------------------------- 1 1 2 2 3 3
SQL> SET RECSEP WRAPPED
SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual
CONNECT BY LEVEL < 4);
A B
---------- ----------------------------------------- 1 1 2 2 3 3
B. Received on Wed Nov 28 2007 - 13:49:58 CST