Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: formatting my results

Re: formatting my results

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Wed, 14 Jul 1999 20:23:25 GMT
Message-ID: <378ff138.19280724@inet16.us.oracle.com>


On Wed, 14 Jul 1999 19:47:31 GMT, chienli_at_uclink4.berkeley.edu wrote:

>Hi I was wondering how I can format my results from an query executed in
>Oracle.
>In a SQL statement where it is SELECT item1 item2 item3 from..., the
>defaulted result returned to you by SQLPLUS looks like
>
>ITEM1 ITEM2 ITEM3
>----- ----- -----
>data1 data2 data3
>data4 data5 data6
>
>But I would like the result to look like
>"data1","data2","data4"
>"data4","data5","data6"
>
>I know I can use '"' to add the quotes and 'heading off' to get rid of
>the column heading, but I can't seem to get the spacing right, using
>either rtrim or ltrim it still leaves me some unwanted spaces.
>Can someone who is more familiar with Oracle help me out on this one?

try:

select '"' || rtrim(ltrim(item1)) || '",' ||
       '"' || rtrim(ltrim(item2)) || '",' ||
       '"' || rtrim(ltrim(item3)) || '"'
  from my_table;

hope this helps.

chris.

>
>thanks
>chienli
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.

--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Jul 14 1999 - 15:23:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US