Re: exporting a table to a flat file in .csv format - CORRECTION!

From: <afz_at_telus.net>
Date: Thu, 28 Aug 2003 00:24:52 GMT
Message-ID: <oZb3b.66343$K44.18402_at_edtnps84>


HI,
just a note, just in case

select replace(trim(field1),',','')
||','||replace(trim(field2),',','')
||','||replace(trim(field3),',','')

||','||etc........

az5

"TurkBear" <john.greco_at_dot.state.mn.us> wrote in message news:sv4nkv8qeof4jvc1gjvgrb6vdi8ug7vmrt_at_4ax.com...
> TurkBear <john.greco_at_dot.state.mn.us> wrote:
>
> >"Jon" <aaa_at_bbb.ccc> wrote:
> >
> >>I am trying to dump data from a table to a flat file in .csv format. I
have
> >>read documentation for sqlplus utility but I have not seen any
information
> >>about this apart from defining specific format for columns. Do you know
if
> >>this is posible from sqplus?
> >>
> >>Thanks
> >>
> >Yes..
> >Read up on spool and colsep and concatenate in the docs, but in general:
> >
> >set heading off
> >set linesize 1000 ( or whatever)
> >set pagesize 0
> >set feedback off
> >set colsep ','
> >spool 'drive:\path\filename'
> >select trim(field1)||trim(field2)||trim(field3)........
> >from your table;
> >
> >have fun...
> >
> >
> Oops..
> Brain Freeze!
>
> The use of concatenation eliminates the colsep character, so I should have
used either:
>
> select field1,field2,field3,etc...
>
> OR
>
> select
trim(field1)||','||trim(field2)||','||trim(field3)||','||etc........
>
> The first will retain the defined width of the data field and place a
comma between each field, while the latter will trim
> training spaces and place a comma between the fields..
>
> Sorry.....
>
>
Received on Thu Aug 28 2003 - 02:24:52 CEST

Original text of this message