• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

to fix thiis

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
tonydba
Asked:
tonydba
1 Solution
 
sdstuberCommented:
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
 
paquicubaCommented:
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
 
Devinder Singh VirdiCommented:
Add
WHERE SPACE_LIMIT != 0 AND .....
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
Devinder Singh VirdiCommented:
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
 
Gerwin Jansen, EE MVETopic Advisor Commented:
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
 
awking00Commented:
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
 
tonydbaAuthor Commented:
Thank youi.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now