Solved

to fix thiis

Posted on 2014-04-03
7
300 Views
Last Modified: 2014-04-08
SQL> SELECT
  2  NAME,
  3  TO_CHAR(SPACE_LIMIT, '999,999,999,999') AS SPACE_LIMIT,
  4  TO_CHAR(SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE,
  5  '999,999,999,999') AS SPACE_AVAILABLE,
  6  ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)
  7  AS PERCENT_FULL
  8  FROM V$RECOVERY_FILE_DEST;
ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)
                                      *
ERROR at line 6:
ORA-01476: divisor is equal to zero


What is the error here? how to fix..
0
Comment
Question by:tonydba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 39976248
space_limit is 0 for at least one row.


how to fix is up to you.  What do you want to be displayed when the space limit is 0?
0
 
LVL 23

Expert Comment

by:paquicuba
ID: 39976254
Put a decode around it (I put 1 but may be wrong)
ROUND((SPACE_USED - SPACE_RECLAIMABLE)/decode(SPACE_LIMIT,0,1,SPACE_LIMIT) * 100, 1)

Or add a condition:
WHERE SPACE_LIMIT > 0
0
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
ID: 39976257
Add
WHERE SPACE_LIMIT != 0 AND .....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:Devinder Singh Virdi
ID: 39976276
Another method:
Try this:-

SELECT
    NAME,
    TO_CHAR(SPACE_LIMIT, '999,999,999,999') AS SPACE_LIMIT,
    TO_CHAR(SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE,
    '999,999,999,999') AS SPACE_AVAILABLE,
    DECODE(to_char(PACE_LIMIT),'0','NaN',to_char(ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)))
    AS PERCENT_FULL
    FROM V$RECOVERY_FILE_DEST;

I haven't ran above SQL, but should work fine.
Before calculating PERCENT_FULL, it will validate if SPACE_LIMIT=0, if it does, then NaN(Not a Number) will be displayed.
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 500 total points
ID: 39976817
SELECT
NAME,
TO_CHAR(SPACE_LIMIT, '999,999,999,999') AS SPACE_LIMIT,
TO_CHAR(SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE,'999,999,999,999') AS SPACE_AVAILABLE,
case SPACE_LIMIT
  when 0 then 'ZERO SPACE_LIMIT'
  else ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)
end AS PERCENT_FULL
FROM V$RECOVERY_FILE_DEST;
0
 
LVL 32

Expert Comment

by:awking00
ID: 39978389
To get the proper answer, you need to answer sdstuber's question as to what you want to see in the case where space_limit is zero. Your basic choices are 0, null, space_used minus space_reclaimable, or some message string (which I wouldn't recommend given the numeric nature of the fields).
0
 

Author Closing Comment

by:tonydba
ID: 39986468
Thank youi.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to recover a database from a user managed backup

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question