Raise the exception when user try to divide the number by 1
**************************************
DECLARE
A NUMBER(2);
B NUMBER(2);
C NUMBER(2);
ONE_DIVIDE EXCEPTION;
BEGIN
A:= &A;
B:= &B;
IF B=1 THEN
RAISE ONE_DIVIDE;
END IF;
C:=A/B;
DBMS_OUTPUT.PUT_LINE(C);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('ZERO DIVIDE');
WHEN ONE_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('ONT DIVIDE');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
****************************************
**************************************
DECLARE
A NUMBER(2);
B NUMBER(2);
C NUMBER(2);
ONE_DIVIDE EXCEPTION;
BEGIN
A:= &A;
B:= &B;
IF B=1 THEN
RAISE ONE_DIVIDE;
END IF;
C:=A/B;
DBMS_OUTPUT.PUT_LINE(C);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('ZERO DIVIDE');
WHEN ONE_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('ONT DIVIDE');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
****************************************
1 Comments:
Click here for CommentsWell done dear bro for contributing to learn DBMS and all other programming language