Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle ZERO_DIVIDE Exception - ORA-01476      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: ZERO_DIVIDE

Definition:
The ZERO_DIVIDE Exception (ORA-01476) occurs when a program attempts to divide a number by zero.

Example Usage:

In this example, if the SELECT INTO statement raises a ZERO_DIVIDE exception, the local handler catches it and sets sal_calc to 3000. Execution of the handler is complete, so the sub-block terminates and execution continues with the INSERT statement.

DECLARE
sal_calc NUMBER(8,2);
BEGIN
INSERT INTO employees_table VALUES(303, 3000, 0);
BEGIN
SELECT salary / commission_pct INTO sal_calc FROM employees_table
WHERE employee_id = 301;
EXCEPTION
WHEN ZERO_DIVIDE THEN
sal_calc := 3000;
END;
INSERT INTO employees_table VALUES(304, sal_calc/100, .1);
EXCEPTION
WHEN ZERO_DIVIDE THEN
NULL;
END;
/
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 157 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?