troubleshooting Question

oracle spooling query into csv eliminating new line character

Avatar of DevSupport
DevSupport asked on
Oracle Database
9 Comments2 Solutions1863 ViewsLast Modified:
Hi Experts,

I am using spool to export a table into a csv file.

I am using the following to create the spool file:

set lines 10000
set trimspool on;
set feedback off;
set tab off;
set space 0;
set pages 0;
set term on;
/*set pagesize 10000;*/
/*set pagesize 5000;*/
col spoolname new_value spoolname
select 'datacollection_full_report_'||to_char(sysdate, 'yymmdd')||'_'||to_char(sysdate, 'hh24_mi_ss')||'.csv' spoolname from dual;
spool '&spoolname'

The table is auto-generated so some of cells have a newline character. In database table it looks ok but in the csv file it writes the new line and breaks the file formatting totally.

I would like to know if there is a way to spool file such that the newline character or space is ignored when csv file is generated.

From the script which generates the values its kind of difficult to eliminate , so I wish there is a way using spool to ignore that newlines.
Senior Oracle DBA

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros