User Define Exception in PL/SQL

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;
****************************************

Previous
Next Post »

1 Comments:

Click here for Comments
Unknown
admin
October 26, 2018 at 7:11 PM ×

Well done dear bro for contributing to learn DBMS and all other programming language

Thank You Unknown For Comment.
Reply
avatar