Subject | Exception handling in loop |
---|---|
Author | Rick Debay |
Post date | 2013-01-10T16:15:16Z |
I want to select a bunch of items and insert them somewhere else. If
the insert fails because of a duplicate primary key or unique
constraint, I want to abandon that particular item and continue with the
rest.
This code outlines my logic. Is this correct for what I'm trying to
accomplish?
BEGIN
FOR SELECT DO BEGIN
BEGIN
INSERT
END /* INSERT */
WHEN GDSCODE unique_key_violation DO
BEGIN
/* NOP */
END
END /* SELECT */
END /* PROCEDURE */
the insert fails because of a duplicate primary key or unique
constraint, I want to abandon that particular item and continue with the
rest.
This code outlines my logic. Is this correct for what I'm trying to
accomplish?
BEGIN
FOR SELECT DO BEGIN
BEGIN
INSERT
END /* INSERT */
WHEN GDSCODE unique_key_violation DO
BEGIN
/* NOP */
END
END /* SELECT */
END /* PROCEDURE */