sqlplus query results with spool file go to display and file
When I run the following script, it writes the results of the query to the file specified AND to the display (I don't want them written to the display). I have tried every set option that seems relevant, but nothing seems to work.
I looked for a sqlplus forum but could not find one. Here is the script; thanks in advance.
start_date="06/02/2011"
end_date="06/02/2011"
queryresultfile="/tmp/report.out"
csvfile="/tmp/report.csv"
sqlplus userid/password << EOF
set echo off
set feedback off
set heading off
set linesize 900
set newpage 0
set pagesize 0
set show off
set serverout off
set space 0
set termout off
set trimspool on
set verify off
spool ${queryresultfile}
select MESSAGE_CREATE_DATE||','||SUBSCRIBER_KEY||','|| HOSTNAME
from (select MESSAGE_CREATE_DATE ,A.SUBSCRIBER_KEY , HOSTNAME from DCL_EVENTS a , CALLTREE_V2 B where HOSTNAME like 'app%' and INSTR(GET_PAA_NUMBER_FROM_SUBSCR_KEY(a.SUBSCRIBER_KEY), B.SUBSCRIBER_KEY) > 0 AND TRUNC(TO_DATE (TO_CHAR (MESSAGE_CREATE_DATE, 'YYYY-MON-DD HH24:MI:SS'),'YYYY-MON-DD HH24:MI:SS') ) BETWEEN TRUNC(TO_DATE('${start_date}', 'MM/DD/YYYY')) AND TRUNC(TO_DATE('${end_date}','MM/DD/YYYY')) Order by MESSAGE_CREATE_DATE);
spool off
EOF
|