Re: Spooling variable length output

From: Chuck Hamilton <chuckh_at_ix.netcom.com>
Date: 1995/11/13
Message-ID: <487pjm$n4m_at_ixnews3.ix.netcom.com>#1/1


Greg Hayes <greg_at_hayford.demon.co.uk> wrote:

>If I want to spool the output from a select statment to a file
>then I SET LINESIZE 338 let us say. However if the data in the
>file is comma delimited (as in "abcd","defg","","1","sfgdtg"),
>thenthe record is always 338 bytes long instead of 29 as in
>the example above. Does anyone have a soution to this.
>--

If you find a way that doesn't involve the operating system, let me know.

What I've done in the past is to append a TAB character (chr(9)) to the end of the line and use the the UNIX 'cut' utility to lop off everything from the TAB on.

In sqlplus...

SET PAGESIZE 0
SET LINESIZE 338

SPOOL myfile
SELECT '"'||col1||'","'||col2||'","'||col3||'"'||chr(9)   FROM mytable;
SPOOL OFF In UNIX...

cut -f1 myfile.lst > temp
mv temp myfile.lst

--
Chuck Hamilton
chuckh_at_ix.netcom.com

Incoming fire has the right of way!
Received on Mon Nov 13 1995 - 00:00:00 CET

Original text of this message