SQL Developer spool command outputs commands as well as results

246 Views Asked by At

I have an sql plus script that uses the SPOOL command to generate a file. I execute it with SQL Developer. When I execute the script, the spool file that is generated only includes the result of the select statement. And that is what I want. But the issue is that when an other user executes the script, it also includes the select-statement itself.

Script:

set pages 0
set lines 32000
set trimspool on
set feedback off
set echo off
set verify off
define vspoolfile = '''c:\temp\spoolfile.txt'''
spool &vspoolfile
select description from query; 
spool off

Result in spoolfile.txt:

> select description from query
Te behandelen
Te plannen

I do not want the first line with '> select description from query' in this file. Because the script behaves differently on the other user's machine than on my machine, I think this is maybe a setting in SQL Developer somewhere? Can I force it to not include the statement itself?

2

There are 2 best solutions below

0
Gary_W On

Add set term off as well. then, save those commands into a file and run it with the @ command from SQLPlus:

@c:\sqlcmd.sql

3
Paul W On

"set term off" only applies to @ script invocations. For directly entered SQL commands, to hide the command itself from the spool file, invoke sqlplus with the -S option. You can also remove the column header with "set heading off".

sqlplus -S user/pass
set heading off
spool test.dat
select * from dual
/
spool off
exit