user defind exception
=================================================================
Declare
v_id number(4):=290;
v_name varchar2(30):='International service';
v_manag number (3):=114;
v_location number(4):=1500;
e_salah exception;
Begin
update departments
set department_name =v_name,
manager_id=v_manag,
location_id=v_location
where department_id =v_id;
if sql%notfound then
raise e_salah;
end if;
commit;
Exception
when e_salah then
insert into departments values
(v_id,v_name,v_manag,v_location);
dbms_output.put_line('Data Baru');
commit;
end;
/
raise exception
=================================================================
Declare
v_id number(4):=290;
v_name varchar2(30):='International service';
v_manag number (3):=114;
v_location number(4):=1500;
e_salah exception;
Begin
update departments
set department_name =v_name,
manager_id=v_manag,
location_id=v_location
where department_id =v_id;
dbms_output.put_line('update berhasil');
if sql%notfound then
RAISE_APPLICATION_ERROR(-20100,'Nomor department salah');
end if;
commit;
end;
/
Comments
Post a Comment