LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-03-2011, 04:03 PM   #1
steven.c.banks
Member
 
Registered: Dec 2007
Location: Virginia
Distribution: RHEL
Posts: 44
Blog Entries: 1

Rep: Reputation: 15
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
 
Old 06-04-2011, 09:02 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

I don't know sqlplus, but I think you could just send all of the output to /dev/null. Put all of the code inside () like this:

(
put all the code here
) > /dev/null

If it still makes output, use "&> /dev/null" instead. The downside is that this will prevent any error messages from being displayed as well.
 
1 members found this post helpful.
Old 06-06-2011, 03:13 PM   #3
steven.c.banks
Member
 
Registered: Dec 2007
Location: Virginia
Distribution: RHEL
Posts: 44

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Thanks. I modified the suggestion slightly, and used:

sqlplus slumc3/oracle4vm << EOF &1>/dev/null

which gives me the SQL errors and warnings without the query results.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I forward a mailbox /var/spool/mail/* file? FireRaven Linux - Newbie 1 02-02-2011 08:46 PM
Display by File Name, File Size, and File Owner using ls akeenabawa Linux - Newbie 9 08-15-2008 02:21 PM
PHP: build query from form entry, then display results in the same form tonedeaf1969 Programming 4 06-22-2007 07:55 AM
Perl file conversion results in a truncated file kshaffer Programming 0 01-31-2005 02:31 PM
insufficient permission to open spool file raypen Linux - Networking 4 04-11-2003 10:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration