I have PL/SQL procedure which copies data from remote database. Both databases are 11g. Most of time the procedure is running fine. However, when the remote database has some unexpected problem (like shutdown, etc... but not all the shutdown cause the problem) it cause the procedure hang and do nothing. My procedure looks like below:
Loop
begin
insert into table as select * from table@remote;
sleep 20 seconds;
exception
when others then
record error...
end;
end loop;
Since we cannot control the remote database, we cannot use materialize view with fast refresh. This is the only approach we can make.
If the process is hang, we can only kill the process and re-start it. Even for killing the process, the process was marked as killed, not totally killed right away.
The exception statement in the above code does catch some errors but not catch this kind of errors.Is there any way to let the procedure detect the problem by itself and avoid the killing?
Many thanks.