-
Select case when syntax
I am trying to use the select case when syntax and have the folllowing
piece of code, which I realize is not that efficient since I am using count
command more than once.
My questions are:
1) How can this code be modified to only use the count command once
2) How can I add select * from v$database_corruption if count>0, without
using the count command again???
As you can see I got as far as printing the count. Any help making
would be greatly appreciated.
sqlplus -s / <
set pages 1000
set line 110
set head off
set veri off
set feed off
set trim on
SELECT CASE
WHEN (SELECT count(1) FROM v\$database_block_corruption) > 0
then ( SELECT count(1) || ' - Corrupted blocks exists in table v\$database_block_corruption' FROM v\$database_block_corruption)
END
FROM DUAL;
EOT
-
select count(*) as "Count of records in v$database_block_corruption"
from v$database_block_corruption;
The output will be 0 or greater.
-
SQL> select count(*) as "Count of records in v$database_block_corruption"
2 from v$database_block_corruption;
select count(*) as "Count of records in v$database_block_corruption"
*
ERROR at line 1:
ORA-00972: identifier is too long
-
Originally Posted by BeefStu
SQL> select count(*) as "Count of records in v$database_block_corruption"
2 from v$database_block_corruption;
select count(*) as "Count of records in v$database_block_corruption"
*
ERROR at line 1:
ORA-00972: identifier is too long
Wasn't the message clear enough?
Replace "Count of records in v$database_block_corruption" by "COUNT"
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|