PL 9 Qeyd
PL 9 Qeyd
PL 9 Qeyd
/*
exception is run time error;
1_system-implicit
2)user defined -explicit
a) using variable exception type
b)using pragma exception_init function oz istediyin number+metn+istediyin ad
c)using raise_application_error-oz istediyin number+metn;
hisse:
declare
raise
handle
*/
declare
var_divided number:=54;
var_divisor number:=0;
var_result number;
ex_div_zero exception;
begin
if var_divisor=0 then
raise ex_div_zero;
end if;
var_result:=var_divided/var_divisor;
dbms_output.put_line(var_result);
exception
when ex_div_zero then
dbms_output.put_line('databyte');
end;
/
--b=a+c
-- -20000 and -20999
declare
age number:=13;
begin
if age <=18 then
raise_application_error(-20008,'you should be 18 or above');
end if;
exception when others then
dbms_output.put_line('databyte');
end;
/
declare
ex_age exception;
age number:=12;
pragma exception_init(ex_age,-20008);
begin
if age<=18 then
raise_application_error(-20008,'you should be 18 or above');
end if;
dbms_output.put_line('it is true');
exception when ex_age then
dbms_output.put_line('databyte');
end;
/