首页 > 解决方案 > 其他过程中的异常而不退出该过程

问题描述

我有一个 REFRESH FAST ON DEMAND 类型的物化视图,我有一个存储过程来刷新几个物化视图。如何在错误日志表中记录异常,但不停止记录错误行的过程,而是继续刷新以下物化视图 2.物化视图产生很多问题,如处理加载错误表?

谢谢你。

create or replace procedure actualizar_vistaM 
is 
begin
DBMS_MVIEW.REFRESH('VIEW 1')

DBMS_MVIEW.REFRESH('VIEW 2')

exception
when others then
INSERT INTO errors VALUES (value1,value2,value3)

end;

标签: oracleoracle10g

解决方案


我想您必须将每次刷新都包含在其自己的 begin-exception-end 块中。

create or replace procedure actualizar_vistaM 
is 
begin
  begin
    DBMS_MVIEW.REFRESH('VIEW 1');
  exception
    when others then
      insert into errors values (...);
  end;
  
  --
  
  begin
    DBMS_MVIEW.REFRESH('VIEW 2');
  exception
    when others then
      insert into errors values (...);
  end;
end;  

推荐阅读