Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Spool from a unix script to a csv/xls file.

532632Nov 19 2009 — edited Nov 19 2009
Dear All,

I have a shell script that selects from teh database and spools into a csv file.

The issue I am facing here is that my data in the csv file is distorted.

The first row is blank, second row has headings, third row is again blank and where the data is a bit lengthy it is slipping to the next line which I don't want.

Can this be rectified somehow?

my script looks like this.
     set feedback off;
      set def off;
      set head off 
spool ${LOGDIR}extract.csv
SELECT 'NAME_PATH' || ',' || 'CODE' from dual
UNION ALL
select function1(p.id) || ',' || function2(p.id)
from table1 p
where  p.type_id = 3345
start with id = 5698
connect by prior p.id = p.parent_id;
spool off;
Here function1 and function2 return text which is quite lengthy (>150 characters).

Thanks.
This post has been answered by Arunkumar Ramamoorthy-Oracle on Nov 19 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 17 2009
Added on Nov 19 2009
5 comments
943 views