Solved

generate a spool without the query

Posted on 2014-02-15
2
433 Views
Last Modified: 2014-02-17
Hello

I want to generate a spool for only a query result.
I execute the following sql commands, but the file not contains only the result :
set heading off;
set echo off;
spool users.sql;
select username from dba_users;
spool off;

Thanks
0
Comment
Question by:bibi92
2 Comments
 
LVL 20

Accepted Solution

by:
flow01 earned 500 total points
Comment Utility
create a file containing the commands
for example qryusers.sql

then execute the command file
@qryusers.sql

you will lose the lines starting with the prompt (mostly SQL>

I have 1 empty line in front and 2 afterwards
add
set newpage none
to the command file and you loose the first empty line
I did not figure out to remove the last 2
0
 
LVL 8

Expert Comment

by:Surrano
Comment Utility
please don't reopen but what I think you need is:
bash# echo "select username from dba_users;" | sqlplus -S user/pass@sid >users.sql

Open in new window

or with here document and query files:
bash# sqlplus -S user/pass@sid >users.sql <<"EOF"
@qryusers.sql
EOF

Open in new window


The -S flag will beautifully trim most if not all of what you don't need.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Cross Outer Join 4 50
Oracle Finace 3 42
Migrating an SQL 2008 database to Oracle 12c 3 59
Schema creation in Oracle12c 6 20
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now