Subject | Re: Exception handling in loop |
---|---|
Author | DanyM |
Post date | 2013-01-14T16:49:46Z |
--- In firebird-support@yahoogroups.com, Thomas Steinmaurer wrote:
HTH,
/Dany
>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.
> > 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
>
HTH,
/Dany