Home » RDBMS Server » Server Administration » Tough SQL*Plus question
Tough SQL*Plus question [message #372226] Fri, 19 January 2001 12:56 Go to next message
Jim K.
Messages: 4
Registered: January 2001
Junior Member
Please help:

Here is a dump of my typing in SQL*PLUS:

SQL> ttitle left 'Jim is cool'
SQL> select 'x' from dual;

Jim is cool
'
-
x

1 row selected.

SQL> select 'x' from dual minus select 'x' from dual;

no rows selected

In the second SELECT above, no rows were selected, so the title 'Jim is cool' did not print??? I would like in a report that I am building to always print the page title - even when no rows are found by the query! Any one know how to accomplish this in SQL*PLUS?
Re: Tough SQL*Plus question [message #372227 is a reply to message #372226] Fri, 19 January 2001 14:03 Go to previous messageGo to next message
Bala
Messages: 205
Registered: November 1999
Senior Member
prompt " Jim is cool "
prompt
select 'x' from dual minus select 'x' from dual;
Re: Tough SQL*Plus question [message #372242 is a reply to message #372226] Mon, 22 January 2001 07:58 Go to previous messageGo to next message
me
Messages: 66
Registered: August 2000
Member
Perform a select you know will return a row.
ie: Sysdate into a no print column

column sdate noprint
ttitle left 'Jim is cool'
select sysdate sdate from dual;
select 'x' from dual minus select 'x' from dual;
Re: Tough SQL*Plus question [message #372243 is a reply to message #372226] Mon, 22 January 2001 08:11 Go to previous messageGo to next message
Jim K.
Messages: 4
Registered: January 2001
Junior Member
That would work great - however - the second query above always returns NULL. The one I am working with will return rows sometimes - so if I used your suggestion, and rows are returned by the second query, then two pages would print... each with a title.

In summary, I have Query A, that will return rows sometimes. I want the title to appear regaurdless, and the 'no rows selected' line to appear also, if there are no rows returned...

This is a toughie.
Re: Tough SQL*Plus question [message #372247 is a reply to message #372226] Mon, 22 January 2001 08:50 Go to previous messageGo to next message
John R
Messages: 156
Registered: March 2000
Senior Member
You could add a union statement into the query, adding a statement that returns nulls. This will always give you one row at least.
Re: Tough SQL*Plus question [message #372248 is a reply to message #372226] Mon, 22 January 2001 08:52 Go to previous messageGo to next message
Jim K.
Messages: 4
Registered: January 2001
Junior Member
Yes, I've thought of that ... But then the '1 row selected' message would appear if the main query returns nothing, instead of what the user wants 'no rows selected' and the title ...

Thanks for the idea !
Re: Tough SQL*Plus question [message #372249 is a reply to message #372226] Mon, 22 January 2001 11:58 Go to previous messageGo to next message
me
Messages: 66
Registered: August 2000
Member
between the two select statements

set embedded on
Re: Tough SQL*Plus question [message #372252 is a reply to message #372226] Mon, 22 January 2001 12:51 Go to previous message
Jim K.
Messages: 4
Registered: January 2001
Junior Member
That's it !!!!

Thank you sooooooo much. You know what's funny? I read that section in my SQL*Plus book by O'reily twice ... Hmm.

Thanks, again!
Previous Topic: Appending a spool file
Next Topic: date problem
Goto Forum:
  


Current Time: Thu May 16 22:55:37 CDT 2024