I have a list of records I want to process and the cursor iterates through them from a table. The procedure just exits when it hits an insert statement and it fails. Is there a way I can ignore the errors and continue processing the following records ?
Cursor C1: for each record: insert into table_t1(col1) values ('...'); <-- Insert statement fails for record 'n' End cursor
I would like for it to not exit out but continue processing from n+1 to the end of cursor.
Any help appreciated.
-
You can always catch the error and CHOOSE to do nothing about it....Joishi Bodio– Joishi Bodio2015年01月08日 16:58:28 +00:00Commented Jan 8, 2015 at 16:58
1 Answer 1
Found it.
You have to declare a continue handler instead of an exit handler. That way even if there is an exception, it goes into the handler and continues with the next record.
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, SQLWARNING
BEGIN ... Code that handles the exception/warning ... END
Explore related questions
See similar questions with these tags.