Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread IMPORT
Fri, Oct 23 2009 12:13 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Is there a way of saying "only import the new stuff" (eg the same primary key) or ignoring when there is a clash?

Roy Lambert
Fri, Oct 23 2009 2:05 PMPermanent Link

"Daniel Kram"
Roy, the way I do it, is I have a key, like you suggested, and then I trap
the error:
   try
     execute query here
   except
     on E: EDatabaseError do
     begin
       sError := lowercase(E.Message);
       // some other error trapping here
       end
       else if (    (pos('duplicate',sError) > 0)
                 or (pos('1004',sError) > 0)
               ) then // error updating/adding with a primary key
       begin
           // do nothing, this is okay.
       end;
    end;
 end;
Sat, Oct 24 2009 3:37 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Daniel


Does that way simply halt the import with a user message or allow it to continue adding new data?

Roy Lambert
Sat, Oct 24 2009 7:39 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Is there a way of saying "only import the new stuff" (eg the same primary
key) or ignoring when there is a clash? >>

You can use an ON ERROR trigger to eat such exceptions.  Just create it
before the import, and then drop it afterwards, or leave it created and make
sure to disable it for normal operation.  Just an empty trigger will do the
trick:

CREATE TRIGGER "ImportError" ERROR INSERT
ON "MyTable"
BEGIN
END

You could also use it to log the rows with errors to a different log/audit
table.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Oct 24 2009 8:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


Hmm, interesting, and yet another of those cases where its "all off and damn well stay off" Smiley

Roy Lambert
Mon, Oct 26 2009 10:07 AMPermanent Link

"Daniel Kram"
Roy:
Since it catches the exception, it contiues importing. You may want to use
Tim's idea with the trigger instead.

Daniel
Image