Home » Other » Client Tools » Spool Command
Spool Command [message #20370] Sat, 18 May 2002 11:08 Go to next message
Sulaiman Gboyega N.
Messages: 17
Registered: April 2002
Junior Member
Hi All,

Please anybody assist me with this siutation.

I want to return the resul of a select into a text file, with the field names as the first row ad each field separated by comma.

I have used the below statements. However, the text file always include the original select statement, the row count returned as well as 'spool off'. Also it did not have the fieldnames.

Please what am I doing wrong?

SET PAGES 0
SET PAGESIZE 0
SET TERMOUT OFF
SET PAUSE OFF
SET NEWPAGE NONE
SET COLSEP ','
SPOOL Filename1.txt
SELECT * FROM tab;
SPOOL OFF

Thanks
Re: Spool Command [message #20374 is a reply to message #20370] Sun, 19 May 2002 09:55 Go to previous message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
SQL> get a
1 set feedback off;
2 set verify off;
3 SET PAGES 0
4 SET PAGESIZE 0
5 SET TERMOUT OFF
6 SET PAUSE OFF
7 SET NEWPAGE NONE
8 SET COLSEP ','
9 SPOOL c:mag.txt
10 SELECT * FROM emp;
11* SPOOL OFF;

SQL> @a

the contents of c:mag.txt is
7369,SMITH ,CLERK , 7902,17-DEC-02, 800, , 20
7499,ALLEN ,SALESMAN , 7698,20-FEB-81, 1600, 300, 30
7521,WARD ,SALESMAN , 7698,22-FEB-81, 1250, 500, 30
7566,JONES ,MANAGER , 7839,02-APR-81, 2975, , 20
7654,MARTIN ,SALESMAN , 7698,28-SEP-81, 1250, 1400, 30
7698,BLAKE ,MANAGER , 7839,01-MAY-81, 2850, , 30
7782,CLARK ,MANAGER , 7839,09-JUN-81, 2450, , 10
7788,SCOTT ,ANALYST , 7566,09-DEC-82, 3000, , 20
7839,KING ,PRESIDENT, ,17-NOV-81, 5000, , 10
7844,TURNER ,SALESMAN , 7698,08-SEP-81, 1500, 0, 30
7876,ADAMS ,CLERK , 7788,12-JAN-83, 1100, , 20
7900,JAMES ,CLERK , 7698,03-DEC-81, 950, , 30
7902,FORD ,ANALYST , 7566,03-DEC-81, 3000, , 20
7934,MILLER ,CLERK , 7782,23-JAN-82, 1300, , 10
Previous Topic: Is it possible to spool data to to fixed format file?
Next Topic: how to limit rows within SQLPlus
Goto Forum:
  


Current Time: Thu Dec 26 07:45:32 CST 2024