Quick Search:
 
 The Oracle ZERO_DIVIDE Exception - ORA-01476      [Return To Index] Jump to:  

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 |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org