Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2004
    Posts
    21

    Unanswered: 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 15:13.

  2. #2
    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

  3. #3
    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.

  4. #4
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    Glad it worked out ...

    Gregg

  5. #5
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    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.

  6. #6
    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.

  7. #7
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •