Home » RDBMS Server » Server Administration » Spooling from SQLPLUS using a .bet or .cmd file
Spooling from SQLPLUS using a .bet or .cmd file [message #372165] Wed, 17 January 2001 10:14 Go to next message
Matt
Messages: 43
Registered: September 1999
Member
I am trying to get SQLplus to spool the results of a query to a file. I can do this from within SQLplus and also if I open and close SQLplus from command line (i.e. what you would write in a .bat or .cmd file to run the query). However, when I do write the command as a .cmd file the spooling does not happen. Can anyone tell me why and also if there's a way to make it happen?
Thanks in advance, Matt
PS I have also tried using a .bat file
Re: Spooling from SQLPLUS using a .bet or .cmd file [message #372166 is a reply to message #372165] Wed, 17 January 2001 10:44 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
Hi,
Spool is sqlplus command.. you can't use it from bat file..What you can do is connect to sqlplus from your bat file and spool it.

e.g:
sample.bat file

sqlplus xyz/xyz@connectstr
spool file.txt
select * from xyz;
spool off

Hope this helps
Suresh
Re: Spooling from SQLPLUS using a .bet or .cmd file [message #372175 is a reply to message #372166] Wed, 17 January 2001 12:27 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
if it does not exit, place "exit;" as the last line of the sql
Re: Spooling from SQLPLUS using a .bet or .cmd file [message #372213 is a reply to message #372166] Thu, 18 January 2001 22:45 Go to previous messageGo to next message
Sajit Nair
Messages: 6
Registered: January 2001
Junior Member
It doesn't work - Oracle ver 7.3.4 and client in Win'98

sqlplus login is working.
It comes and halts at SQL>
the other commands doesn't work inside SQL>
If i type exit....then all commands appear in DOS prompt.

Pls. help.
Re: Spooling from SQLPLUS using a .bet or .cmd file [message #372232 is a reply to message #372165] Fri, 19 January 2001 17:29 Go to previous message
bc
Messages: 4
Registered: December 2000
Junior Member
Create a .bat file as
sqlplus -s scott/tiger@orcl @try.sql

Create a file try.sql
spool try.log
select * from xyz;
spool off
exit

hth
bc
Previous Topic: Tablespace % used query
Next Topic: SQL Loader
Goto Forum:
  


Current Time: Fri May 17 01:19:16 CDT 2024