Withou dividing by zero.
Code:
declare
n1 number;
n2 number;
result number;
begin
n1:=10;
n2:=2;
result:=n1/n2;
dbms_output.put_line(N1/N2);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Divided by zero is not allowed.');
END;
Result:
5
Dividing by Zero
code:
declare
n1 number;
n2 number;
result number;
begin
n1:=10;
n2:=0;
result:=n1/n2;
dbms_output.put_line(N1/N2);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Divided by zero is not allowed.');
END;
Result:
Divided by zero is not allowed.
No comments:
Post a Comment