Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Moxy1 (Programmer) (OP)
30 Jun 09 16:01
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
 
jdemmi (MIS)
30 Jun 09 20:49
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"

carp (MIS)
2 Jul 09 16:19
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?
SantaMufasa (TechnicalUser)
2 Jul 09 16:32
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.

santaMufasa
(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."

SantaMufasa (TechnicalUser)
2 Jul 09 16:34
Sorry...I meant Moxy1 (original poster), not JDemmi (responder).

santaMufasa
(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."

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close