Reputation:
Using sqlplus.exe I'm looking for a way to write sqlplus output to a file.
Is there anyway I can do that, currently the output is written only to the console.
Upvotes: 76
Views: 263269
Reputation: 1562
just to save my own deductions from all this is (for saving DBMS_OUTPUT output on the client, using sqlplus):
>
windows CMD redirection. the passwords etc. can be given to the empty prompt, after invoking sqlplus. also the "/" directives and the "exit;" command should be put either inside the script, or given interactively as the password above (unless it is specified during the invocation of sqlplus)Upvotes: 3
Reputation: 359
In windows type this command:
sqlplus.exe username/password@servicename @yourquery.sql > out.txt
besides, you should write an exit
command at the end of "yourquery.sql" file.
Upvotes: 2
Reputation: 31
Make sure you have the access to the directory you are trying to spool. I tried to spool to root and it did not created the file (e.g c:\test.txt
). You can check where you are spooling by issuing spool
command.
Upvotes: 3
Reputation: 26333
Also note that the SPOOL
output is driven by a few SQLPlus settings:
SET LINESIZE nn
- maximum line width; if the output is longer it will wrap to display the contents of each result row.
SET TRIMSPOOL OFF|ON
- if set OFF
(the default), every output line will be padded to LINESIZE
. If set ON
, every output line will be trimmed.
SET PAGESIZE nn
- number of lines to output for each repetition of the header. If set to zero, no header is output; just the detail.
Those are the biggies, but there are some others to consider if you just want the output without all the SQLPlus chatter.
Upvotes: 42
Reputation:
You may use the SPOOL command to write the information to a file.
Before executing any command type the following:
SPOOL <output file path>
All commands output following will be written to the output file.
To stop command output writing type
SPOOL OFF
Upvotes: 84