I have a query called in a CSH script which is a simple select. I would like to write the result of the select statement in a a flat file but when i set the "SET HEADING OFF" and "SET FEEDBACK OFF", i get a blank line written to the flat file. When i executed the query in SQLPLUS and the settings off, i really had some spaces.

e.g.
SQL> SET HEADING OFF
SQL> SET FEEDBACK OFF
SQL> select employee_id||','||first_name||','||last_name row_list
> from employees;

191,Randall,Perkins
192,Sarah,Bell
193,Britney,Everett
194,Samuel,McCain
....

I got a blank in the first result where the column name used to reside. And in between the result set, i also get some blank lines because of the default page size. No matter how i set the page size, i still don't know how will i know how long the data/result will be, meaning at one point there will still be a blank space that will be written in the flat file. Is this something that can be set to SQLPLUS or in the CSH script??

Are you using the SPOOL command to generate the flat file ?

I am not using the SPOOL. This is how i take results from my select query in my CSH script:

$ORACLE_HOME/bin/sqlplus -s hr/hr@xe @write_to_file.sql > result.dat

Where write_to_file.sql contains:

set heading off
set feedback off

select employee_id||','||first_name||','||last_name row_list
from employees;

quit;

It is because when i used the SPOOL, it is also printing the SQL commands I executed in SQLPLUS. I need the flat file in some other programs as it is.

Thank you