Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: formatting my results
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.
![]() |
![]() |