Re: How to do linefeed in SQL?

From: Brian Membrey <horsemth_at_mel.switch.net.au>
Date: 1997/02/21
Message-ID: <01bc204d$dd86c960$46a966cb_at_default>#1/1


OR you can insert a linefeed directly via the CHR function PROVIDED the linefeed is embedded in a concatenated string ....this can have some advantages as you can DECODE the line and replace the linefeed with a NULL character if the line is blank and you don't want blanks on in the address ..something like

select 'first line' || decode('first line',NULL,NULL,CHR(10)) ||
       'second line' || decode(second line,NULL,NULL,CHR(10)) ||
       '' || decode('',NULL,NULL,CHR(10)) ||
       'fourth line' 

from dual

first line
second line
fourth line

BUT strangely, it doesn't work if the linefeed is at the end of line (maybe because SQL thinks you typed it(?) ...

select 'first line' || CHR(10),
       'second line' || CHR(10),
       'third line' || CHR(10),
       'fourth line' 

from dual;

first line second line third line fourth line

greg teets <teetshd_at_ucbeh.san.uc.edu> wrote in article <330da394.53825785_at_news.ececs.uc.edu>...
> On Fri, 21 Feb 1997 11:45:33 GMT, teetshd_at_ucbeh.san.uc.edu (greg
> teets) wrote:
>
> >This seems like it should be pretty simple but I can't see how to do
> >it from the books.
> >
> >If you wanted to make address labels using each column as a row on the
> >label, what would you add to the following SQL to make the necessary
> >linefeeds when the column changes?
> >
> >select salutation||' '||first_name||' 'last_name,
> > address_1,
> > address_2,
> > city||', '||state||' '||zip
> >from customer;
> >
> >Thanks,
> >Greg
>
> I found "NEWLINE" under the column parameter.
> Easier done than found. <g>
>
> Thanks
> Greg
>
Received on Fri Feb 21 1997 - 00:00:00 CET

Original text of this message