-
Stop Proceed if error
Hi All,
I have a package to run all the procedures.
Basically, all the procedure performing the DML command.
For instance, I have package as follow.
PACKAGE test IS
procedure A;
procedure B;
procedure C;
procedure D;
function run_all return boolean;
END;
PACKAGE BODY test IS
procedure a is
begin
insert into ....
WHEN OTHERS THEN
....
end;
procedure b is
begin
delete into ....
WHEN OTHERS THEN
....
end;
procedure C is
begin
update into ....
WHEN OTHERS THEN
....
end;
procedure d is
begin
insert into ....
WHEN OTHERS THEN
....
end;
function run_all return boolean is
begin
a;
b;
c;
d;
end;
Question : how to ask the program to exit if there is error on b without continuing the procedure c and d ? must I have a check for every single procedure ?
Thanks
-
Define an OUT variable ERRCODE in each procedure. For example 0 for success 1 for failure.
If the ERRCODE from the prevous procedure is > 0 then exit.
-
You could only handle specific errors in the individual procedures (use whatever exception handlers are appropriate rather than a generic "when others"). Let the other errors propogate up to the function. You can handle them there and decide if processing should continue or stop.
hth,
pr