Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the desired sql formatted results

Status
Not open for further replies.

dps

Programmer
Feb 2, 2001
157
GB
I am currently trying to spool off the results of multiple sql statements(select empid from emp where deptno = 20 select ename from emp where deptno = 25, etc) contained within a file. Running this for the moment via command line in sqlplus. Not all my statements will return results and a 'nice to have' would be a spooled output of only those statements which did return something.

What I want is the required spooled output to give me the column name for each of the rows returned, ex.
empid
-----
12

ename
-----
Gym
 
DPS,

1) The following SPOOL-related commands should surround your SELECTs:
Code:
spool <output file name>
(SELECTs go here)
spool off

2) To get output just for the SELECTs with a results set, just issue the following SQL*Plus directive:
Code:
SET FEEDBACK OFF

Let us know if this produces the results you wanted.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
@ 17:02 (07Feb05) UTC (aka "GMT" and "Zulu"),
@ 10:02 (07Feb05) Mountain Time

Click here to Donate to Tsunami Relief. 100% of your contributions here go to the victims...0% to administration.
They were "The First-Responder" to the disaster, with relief deliveries arriving before Red Cross and U.S. aid.
 
The thing is My resultant spooled output from running the file containing the separate sql statements is not showing any headings for the values returned, i.e empid, ename....
 
DPS,

To ensure that you get headings as a result of SQL SELECTs, add the following to your script(s):
Code:
set heading on
set pagesize <some positive-integer value, such as "35">

Please re-try and disclose your findings here.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
@ 16:27 (08Feb05) UTC (aka "GMT" and "Zulu"),
@ 09:27 (08Feb05) Mountain Time

Click here to Donate to Tsunami Relief. 100% of your contributions here go to the victims...0% to administration.
They were "The First-Responder" to the disaster, with relief deliveries arriving before Red Cross and U.S. aid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top