I am trying to output the results of a query to a text file using the SPOOL in SQLPLUS. My code look like this:
The resulting text file should look like this:
Column1: theContentsOfCol1 |P|2.3
Look for | theContentsOfCol2
More Text |
Column1: theContentsOfCol1 |P|2.3
Look for | theContentsOfCol2
More Text |
...etc...
Unfortunately, I get a text file with 2 problems:
1. The results are placed on 4 lines
2. A blank line is placed every 13 lines
Note that the results in line 2 in the above example routinely span more than 80 characters. I have played with line size on page size but changing these settings cause more blank lines to appear. I finally broke down and used TOAD to save as to a text file, but I'd really like to know why the SPOOL did not work in SQLPLUS (especially why a blank line was placed every 13 lines)
Thanks
Code:
SET head OFF
--set pagesize 40
SET termout OFF
SET feedback OFF
SET verify OFF
SET timing OFF
SET echo OFF
SET linesize 80
SET trim ON
spool C:\outfile.txt;
select 'Column1: '||col1 ||'|P|2.3'|| Chr(10)||'Look for |'|| col2 || Chr(10) ||'More Text |'||Chr(13)
from (SELECT max(col1), col2
FROM myTable
group by col1)
;
--220,000 rows
The resulting text file should look like this:
Column1: theContentsOfCol1 |P|2.3
Look for | theContentsOfCol2
More Text |
Column1: theContentsOfCol1 |P|2.3
Look for | theContentsOfCol2
More Text |
...etc...
Unfortunately, I get a text file with 2 problems:
1. The results are placed on 4 lines
2. A blank line is placed every 13 lines
Note that the results in line 2 in the above example routinely span more than 80 characters. I have played with line size on page size but changing these settings cause more blank lines to appear. I finally broke down and used TOAD to save as to a text file, but I'd really like to know why the SPOOL did not work in SQLPLUS (especially why a blank line was placed every 13 lines)
Thanks