[英]Continue loop in reading excel rows even when an exception occurred in PL/SQL
以下是代碼概述:
PROCEDURE
BEGIN
WHILE LOOP --loop each row
--Read each row and add in table
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS
--log error
ROLLBACK;
END;
例如:有5行。 第三行中有錯誤。 程序在讀取錯誤行后立即停止,使它旁邊的其他行不被評估/讀取。 我的目標是轉到異常之后,它將輸出該行並繼續讀取其他行。 那么,如果發生異常,如何返回到循環呢?
試試這個,那么您將只在內部匿名塊中緩存錯誤:
PROCEDURE
BEGIN
WHILE LOOP --loop each row
BEGIN
--Read each row and add in table
COMMIT;
EXCEPTION
WHEN OTHERS
--log error
ROLLBACK;
END;
END LOOP;
END;
嘗試在循環本身中使用獨立的PL / SQL塊。
BEGIN
WHILE LOOP --loop each row
BEGIN
--Read each row and add in table
COMMIT;
EXCEPTION --Catch the exception here and print the data and it will move on
END;
END LOOP;
EXCEPTION
WHEN OTHERS
--log error
ROLLBACK;
END;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.