Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Totally misundertanding a Query with ORA-01476: divisor is equal to zero

JuanMJan 6 2017 — edited Jan 6 2017

Hi guys,

Please give an advise about what I am missunderstanding in following issue I have.

Database version:

SQL>SELECT banner FROM v$version;

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

PL/SQL Release 11.2.0.1.0 - Production

"CORE 11.2.0.1.0 Production"

TNS for Linux: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 - Production

The issue I have is...

I don't understand why the following query,

SELECT limit_

      ,current_usage

      ,maximum_limit

      ,pct_max_limit

      ,ROUND(current_usage*100/maximum_limit) pct_used

FROM

(

   SELECT 'DB Sessions' limit_, p.cnt maximum_limit, c.cnt current_usage, 85 pct_max_limit

   FROM (SELECT TO_NUMBER(value) cnt FROM v$parameter WHERE name = 'sessions') p

       ,(SELECT COUNT(*) cnt FROM v$session) c

   UNION ALL

   SELECT 'DB Processes' limit_, p.cnt maximum_limit, c.cnt current_usage, 85 pct_max_limit

   FROM (SELECT TO_NUMBER(value) cnt FROM v$parameter WHERE name = 'processes') p

       ,(SELECT COUNT(*) cnt FROM v$process) c

   UNION ALL

   SELECT 'DB Files' limit_, p.cnt maximum_limit, c.cnt current_usage, 85 pct_max_limit

   FROM (SELECT TO_NUMBER(value) cnt FROM v$parameter WHERE name = 'db_files') p

       ,(SELECT SUM(cnt) cnt FROM (SELECT COUNT(*) cnt FROM v$datafile

                                   UNION ALL

                                   SELECT COUNT(*) cnt FROM v$tempfile

                                  )

        ) c

   UNION ALL

   SELECT 'ASM DiskGroups' limit_, p.cnt maximum_limit, c.cnt current_usage, 85 pct_max_limit

   FROM (SELECT 63 cnt FROM dual) p /*ASM Storage Limits 11gr2*/

       ,(SELECT COUNT(*) cnt FROM v$asm_diskgroup) c

   UNION ALL

   SELECT 'ASM Disks' limit_, p.cnt maximum_limit, c.cnt current_usage, 85 pct_max_limit

   FROM (SELECT 10000 cnt FROM dual) p /*ASM Storage Limits 11gr2*/

       ,(SELECT COUNT(*) cnt FROM v$asm_disk) c

)

--WHERE

;

;

that returns in my DEV environment the following ouput

LIMIT_CURRENT_USAGEMAXIMUM_LIMITPCT_MAX_LIMITPCT_USED
DB Sessions793792852
DB Processes802500853
DB Files1792008590
ASM DiskGroups063850
ASM Disks010000850

When I put the following WHERE clause

WHERE ROUND(current_usage*100/maximum_limit) >= 85

Returns the following error (alse tested in 11.2.0.3):

ORA-01476: divisor is equal to zero

01476. 00000 -  "divisor is equal to zero"

*Cause:   

*Action:

I am totally lost in this .....

Can you help me please?

Thanks in advance.

Regards,

Juan M

This post has been answered by AndrewSayer on Jan 6 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 3 2017
Added on Jan 6 2017
11 comments
1,368 views