If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Trim blanks from spooled output

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-20-04, 14:10
jagged30net jagged30net is offline
Registered User
 
Join Date: Jan 2004
Posts: 21
Trim blanks from spooled output

Does anyone have an example of SQLPlus code to create a delimited file without producing embedded blanks? I've tried several 'set' options - including trimspool - but still get spaces after each column in the output file.

Please copy responses to: greg_pearson@fanniemae.com.

Last edited by jagged30net; 09-20-04 at 14:13.
Reply With Quote
  #2 (permalink)  
Old 09-20-04, 14:15
gbrabham gbrabham is offline
Registered User
 
Join Date: Apr 2003
Location: Greenville, SC (USA)
Posts: 1,155
Here's an example of a tab delimited file ... Replace the chr(9) with ','
if you want a comma delimited file ...

set linesize 120
set header off
set pagesize 0
set feedback off
set trimspool on

spool c:\test.txt

select username||chr(9)||sid||chr(9)||serial#||chr(9)||pr ogram from v$session;

spool off

HTH
Gregg
Reply With Quote
  #3 (permalink)  
Old 09-20-04, 14:29
jagged30net jagged30net is offline
Registered User
 
Join Date: Jan 2004
Posts: 21
Got it, thanks. In addition to my delimeter, I was using commas in the select string to separate fields.
Reply With Quote
  #4 (permalink)  
Old 09-20-04, 14:34
gbrabham gbrabham is offline
Registered User
 
Join Date: Apr 2003
Location: Greenville, SC (USA)
Posts: 1,155
Glad it worked out ...

Gregg
Reply With Quote
  #5 (permalink)  
Old 09-20-04, 17:06
beilstwh beilstwh is offline
Lead Application Develope
 
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,343
Oh and if you are on a unix box and want to stip off the padded blanks on the right, you could do the following

spool xyzzy.txt
.......
spool off
host sed -e 's/\ \ *$//' xyzzy.txt >xyzzy.cvs
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
Reply With Quote
  #6 (permalink)  
Old 09-21-04, 08:11
shoblock shoblock is offline
Registered User
 
Join Date: Apr 2004
Posts: 246
and regardless of o/s, trimspool serves that exact purpose, so bother with the extra step. I believe trimspool became available in v8, so it might be time to revist those reports you wrote on v7.
__________________
Give a man a fish, you feed him for a day. Club him over the head with a fish, he'll leave you alone.
Reply With Quote
  #7 (permalink)  
Old 09-21-04, 13:35
beilstwh beilstwh is offline
Lead Application Develope
 
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,343
Quote:
Originally Posted by shoblock
and regardless of o/s, trimspool serves that exact purpose, so bother with the extra step. I believe trimspool became available in v8, so it might be time to revist those reports you wrote on v7.
Cool, makes my life easier.... Thanks
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On