My bad, use: SELECT field1 ||','|| field2 ||','|| field3 ||','|| field4 ||','|| field5
Main Topics
Browse All TopicsI am trying to create a CSV file using SQL*Plus. I'd like the file to be comma separated. For example, I'd like the file to look something like this:
field1row1,field2row1,fiel
field1row2,field2row2,fiel
Instead I am getting something like this (with extra white space filling up the size of each column:
field1row1 ,field2row1 ,field3row1 ,field4row1 ,field5row1
field1row2 ,field2row2 ,field3row2 ,field4row2 ,field5row2
How do I get rid of the white space?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Yes, reset the seperator to its default, although that shouldn't be an issue using this concatenation approach.
The approach by ppionon is viable if you have the I/O cycles to manipulate each column of each row. And as you may be aware, there's the backend approach to open an ODBC connection from Excel into the Oracle db, and retrieve the data using the cross-platform application.
However, if you really wish to blow the socks off your performance wait time, add SET ARRAYSIZE 5000 in order to have the client get more rows at once (the default is 15, left over from Oracle 6 or 7). Best little known secret.
HTH,
dvz
Thanks, virdi_ds. I already had set trimspool on.
ppinon, I tried using trim() around each column retrieved but this did not affect the csv file. I still have all the white space after the values.
dvz, this works perfectly. Thank you. I must say, though, that it seems like there should be a simpler solution than making the entire select statement include a single column to select. I would have thought that the trim() function would work or that Oracle would have some other setting to remove the trailing whitespace in csv files. In any case, thank you very much for your help.
Business Accounts
Answer for Membership
by: dvzPosted on 2009-10-28 at 09:03:37ID: 25684743
SELECT field1 ||,|| field2 ||,|| field3 ||,|| field4 ||,|| field5