problem with spool off

I want to write the output of the sql statement into a text file. for that i am doing some thing like this,

spool filename
set head off
Select Statement
spool off

then, it is creating a file but not writing anything.
if i comment the line 'spool off', it is working fine.
can anyone have a clue.
thanks in advance.
Who is Participating?
dbrowerConnect With a Mentor Commented:
Your problem may be caused by not properly ending your SQL statement (missing the ; ) in your script.

If this is a script file try:

set head off
spool customer.txt
select * from customer_master
spool off

everything else looks OK

did you check to see that the file system you are trying to write to is not full??

Check you have turned echo off.

Try after SET ECHO ON

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

spool does not have any impact of echo on/off.

ur steps are right.

can u be more specific means can u write ur exact code ?

The only way it can create a file but write no records to it (OKB) is when you forgot to say Spool off after the select statement.

If you say spool off it will always flush what it has to the file, Till you specify spool off it will not flush the dat to the file so the file will read 0KB.
varadishAuthor Commented:
dear sampathi,
what u said is absolutely right.
but the problem is, here it is happening just the opposite way.

the exact code is simply just like this

spool customer.txt
set head off
Select * from customer_master
spool off

help please.....

jtriftsMI and AutomationCommented:
May I sugget you check your start-in directory for sqlplus?  It could be that the file is being written to another location, whereas you might have created the first empty copy by stating a spool off incorrectly.


spool <filename.ext>
anything you type from this point should appear in the spool file.
If you put the echo on, each query will re-state itself onscreen to show you what it is running.
spool off
at this point the spool buffer is written to the file.
varadishAuthor Commented:
yes, we tried with ending the statements with ; and it worked.
thanks for that
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.