Continuing Inserts in Oracle when exception is raised

后端 未结 5 704
滥情空心
滥情空心 2020-12-11 09:39

I\'m working on migration of data from a legacy system into our new app(running on Oracle Database, 10gR2). As part of the migration, I\'m working on a script which inserts

5条回答
  •  萌比男神i
    2020-12-11 10:02

    DECLARE
       cursor;
    BEGIN
        loop for each row  in cursor
          BEGIN  -- subBlock begins 
             SAVEPOINT startTransaction;  -- mark a savepoint
     -- do whatever you have do here
             COMMIT;         
          EXCEPTION
             ROLLBACK TO startTransaction;  -- undo changes
          END;  -- subBlock ends
       end loop;
    END;
    

提交回复
热议问题