--- In [email protected], Thomas Steinmaurer wrote:
>
> > 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 */
>
> I guess this should be:
>
> BEGIN
> FOR SELECT DO
> BEGIN
> INSERT
> WHEN GDSCODE unique_key_violation DO
> BEGIN
> /* NOP */
> END
> END /* SELECT */
> END /* PROCEDURE */
>
>
>
> Regards,
> Thomas
>
I do similar things if i remeber correctly. Though mostly using INSERT INTO.
I'm usually lazy and do WHEN ANY where i log the "errors" into a VARCHAR or
BLOB. This is especially nice if the user has the option (after execution) to
committ or rollback the transaction. It strikes me as quite simple to set up a
test-case for this though.
HTH,
/Dany