Reputation: 1044
Is it possible to set the server output only into the spool file and not in the shell ?
set serveroutput on
spool log.txt
exec MY_PROCEDURE();
spool off
Inside MY_PROCEDURE
I have this :
DBMS_OUTPUT.put_line('Hello World');
I would like to put Hello World
only in log.txt
, not in the screen shell.
Upvotes: 0
Views: 2805
Reputation: 1973
The sqlplus way to do this, if you run it as script, is to set 'termout' ot ON or OFF. Output is always spooled to a file, if spooling is activated, the output is written to the terminal (more exactly to stdout on Linux) if TERMOUT is ON, which is the default. So to suppress the output do
set serveroutput on
spool log.txt
set termout off
exec MY_PROCEDURE();
set termout on
spool off
Upvotes: 0
Reputation: 4874
Simplest way is to pipe the unix output to /dev/null
$ sqlplus -S user/password @test.sql > /dev/null
$ cat test.sql
set serveroutput on
set feedback off
spool log.txt
exec dbms_output.put_line('This is great!! and working');
spool off;
exit;
$ cat log.txt
This is great!! and working
$
Upvotes: 1