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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Title Issue

Status
Not open for further replies.

Moxy1

Programmer
Aug 29, 2002
75
US
I'm running a series of SQLs and would like to have title per SQL. However if no rows is returned for one of the SQLs I'm not getting the title for that specific SQL:

SQL:
Code:
ttitle 'sql 1'
select count(*)
from table1
/
ttitle 'sql 2'
select count(*)
from table2
/
ttitle 'sql 3'
select count(*)
from table3
/

output:
Code:
sql 1

count
-----
3

no rows selected

sql 3

count
-----
20

1 row selected
 
A case statement should work...

select case when count(*) is null then 'no records' else to_char(count(*)) end as count from table2

-- Jason
"It's Just Ones and Zeros
 
This does not make sense. All three of these queries will return one row. For table2, if no rows are found, the query will return a result of 0. There is something wrong with this scenario. Moxy - have you left something out of the queries you've supplied?
 
JDemmi,

To illustrate what Carp is saying, here is execution of your posted code, against tables that match content that you assert:
Code:
SQL> ttitle 'sql 1'
SQL> select count(*)
  2  from table1
  3  /

Thu Jul 02                               page    1
                      sql 1

  COUNT(*)
----------
         3
SQL> ttitle 'sql 2'
SQL> select count(*)
  2  from table2
  3  /

Thu Jul 02                               page    1
                      sql 2

  COUNT(*)
----------
         0
SQL> ttitle 'sql 3'
SQL> select count(*)
  2  from table3
  3  /

Thu Jul 02                               page    1
                      sql 3

  COUNT(*)
----------
        20
Let us know if you have a rationale for my results differing from your results.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
Sorry...I meant Moxy1 (original poster), not JDemmi (responder).

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top