Hide SQL > statements in the spool file

Haadiya  picture Haadiya · Jun 21, 2015 · Viewed 14.6k times · Source

I want to hide the "SQL> @test.sql" and "SQL> spool off" in the file test.txt(spool file)

my steps

set heading off 
set pages 0 
set trimspool on 
set lines 120 
set feedback off 
set echo off 
set termout off 
spool test.txt
@test.sql
spool off

test.txt

SQL> @test.sql                              
2002452199  2797    9/1/2014    9/30/2014   OO56128665          934 90087318    1   6046
10226342            ##########  0   0                   


SQL> spool off

Answer

doberkofler picture doberkofler · Jun 22, 2015

This example script (test.sql):

set heading off verify off feedback off echo off term off pagesize 0 linesize 10000 trimout on trimspool on timing off
spool test.log
SELECT 'content of spool file' FROM dual;
spool off

when run:

>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.1.0 Production on Mon Jun 22 08:46:58 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Last Successful login time: Mon Jun 22 2015 08:46:52 +02:00
Connected to:
Oracle Database 12c Release 12.1.0.1.0 - 64bit Production
SQL> @test.sql
SQL> exit
Disconnected from Oracle Database 12c Release 12.1.0.1.0 - 64bit Production

generates a "clean" spool file:

>type test.log
content of spool file