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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL*Plus reporting question

Re: SQL*Plus reporting question

From: Vince <vinnyop_at_yahoo.com>
Date: 22 May 2002 09:52:40 -0700
Message-ID: <56e2f55a.0205220852.43309a87@posting.google.com>


d_newsham_at_hotmail.com (D Newsham) wrote in message news:<c883e8dd.0205211008.3b605ef1_at_posting.google.com>...
> Hi,
>
> I hope I am posting to the right group. If not please let me know as
> I don't like to cross-post.
>
> I have written a query to produce a csv file from SQL*Plus. I also
> need the headers to come out as a single line, comma separated. Can
> this be done?
>
> So far I have discovered that I can turn the headers off, make them
> come out in one single string, or be separated by space with an
> underline underneath. I really need the headers to come out in a
> single, comma separated line so my client can import it into Excel
> without having to type in all of the column headers.
>
> Here is what I have so far (actual file contains about 60 columns):
>
> set heading off pagesize 0 linesize 2000 feedback off
>
> spool testfile
> SELECT
>
> column_1||','||
> column_2||','||
> column_3||','||
>
> FROM test_table
> order by column_1,column_2,column_3
> /
> spool off
>
>
> Thanks!
> Dina

If you knew the column count, you could play around with the following:

select min(decode(column_id, 1, column_name, null))||','||
       min(decode(column_id, 2, column_name, null))||','||
       min(decode(column_id, 3, column_name, null))
from user_tab_columns
where table_name = 'table_x'
union
select col1||','||col2||','||col3...
from table_x Received on Wed May 22 2002 - 11:52:40 CDT

Original text of this message

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