Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Problem on CachedUpdates
Sat, Dec 28 2013 9:12 AMPermanent Link

Ömer UZUNER

Mental Yazilim ve Dan. Hiz. San. ve Tic. Ltd. Sti.

I'm getting "Dublicate Error" on ApplyCachedUpdates because of unique field but there is no duplicate data before ApplyCachedUpdates and I'm clearing table datas before append records.

 ------------------------------------------- Code -------------------------------------------
 RouterStrList.Text := 'Main Router ¨ 318C-954F-FF6F-B295 ¨ 78.46.163.220 ¨ 443 ¨ 1' + #13#10
                                'Test Router ¨ 1A6F-AFEF-48EF-AEED ¨ 192.168.2.54 ¨ 443 ¨ 2';
 . . .
 Try
   //-------------------------------------------------------------------------------------------------------------------
   if (tbRouters.Active = False) then tbRouters.Active := True else tbRouters.Refresh;
   //-------------------------------------------------------------------------------------------------------------------
   tbRouters.BeginCachedUpdates;
   tbRouters.First;
   while not tbRouters.Eof do Table.Delete;
   //-------------------------------------------------------------------------------------------------------------------
   for I := 0 to RouterStrList.Count - 1 do begin
     TempStr := RouterStrList.Strings[I];
     tbRouters.Append;
     tbRouters.FieldByName('RouterName'  ).AsString := Copy(TempStr,      1, X1      - 1);
     tbRouters.FieldByName('SecurityCode' ).AsString := Copy(TempStr, X1 + 3, X2 - X1 - 3);
     tbRouters.FieldByName('RouterIP'        ).AsString := Copy(TempStr, X2 + 3, X3 - X2 - 3);
     tbRouters.FieldByName('RouterPort'     ).AsString := Copy(TempStr, X3 + 3, X4 - X3 - 3);
     tbRouters.FieldByName('Index'             ).AsString := Copy(TempStr, X4 + 3,          10);
     tbRouters.Post;
   end;
   //-------------------------------------------------------------------------------------------------------------------
   tbRouters.ApplyCachedUpdates;
 Except
   On E : Exception do begin
   Application.MessageBox(PChar(E.Message), '');
   if tbRouters.CachingUpdates then tbRouters.CancelCachedUpdates;
   end;
 End;
 . . .
 ------------------------------------------- Error Message -------------------------------------------
 ElevateDB Error #1305 Error loading the updates for the database ClientDB
 (Unknown error occurred with the table Routers (ElevateDB Error #1004 The
 unique constraint idxSecurityCode for the table Routers has been violated
 (Duplicate key 1A6F-AFEF-48EF-AEED found)))

 there is one record in table before this operation and it contain '1A6F-AFEF-48EF-AEED' but I delete this record in code and after I re append and error become. Is it a bug or there is a mistake in code?
Mon, Dec 30 2013 6:39 AMPermanent Link

Adam Brett

Orixa Systems

Ömer

I would just suggest trying this:

   tbRouters.BeginCachedUpdates;
   tbRouters.First;
   while not tbRouters.Eof do Table.Delete;
   tbRouters.FlushBuffers; //-------------- ADD THIS.
   //-------------------------------------------------------------------------------------------------------------------
   for I := 0 to RouterStrList.Count - 1 do begin
     TempStr := RouterStrList.Strings[I];
     tbRouters.Append;

If that is no good it might even be worth closing and reopening the table after the "Delete".

Finally: I have never used the command BeginCachedUpdates ... it might be the cause of the problem. I think you could remove it without a problem.
Mon, Dec 30 2013 6:57 AMPermanent Link

Ömer UZUNER

Mental Yazilim ve Dan. Hiz. San. ve Tic. Ltd. Sti.

Hi Adam;

I try all this possibilities but nothing solve this issue.
Sample code of the Issue attached.

Ömer UZUNER

-------------------------------------------------------------------------------------------------

Adam Brett wrote:
Ömer
I would just suggest trying this:

   tbRouters.BeginCachedUpdates;
   tbRouters.First;
   while not tbRouters.Eof do Table.Delete;
   tbRouters.FlushBuffers; <-------------- ADD THIS.
   for I := 0 to RouterStrList.Count - 1 do begin
     TempStr := RouterStrList.Strings[I];
     tbRouters.Append;
   end;

If that is no good it might even be worth closing and reopening the table after the "Delete".

Finally: I have never used the command BeginCachedUpdates ... it might be the cause of the problem. I think you could remove it without a problem.



Attachments: CachedUpdates.rar
Mon, Dec 30 2013 10:42 AMPermanent Link

Raul

Team Elevate Team Elevate


Do you have a primary key on the table ?

What type is it? (it can't be identity to use with cachedupdates)

Raul


On 12/28/2013 9:12 AM, Ömer UZUNER wrote:
> I'm getting "Dublicate Error" on ApplyCachedUpdates because of unique field but there is no duplicate data before ApplyCachedUpdates and I'm clearing table datas before append records.
Fri, Jan 3 2014 11:25 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ömer,

<< I'm getting "Dublicate Error" on ApplyCachedUpdates because of unique
field but there is no duplicate data before ApplyCachedUpdates and I'm
clearing table datas before append records. >>

Fixed in 2.15.

Tim Young
Elevate Software
www.elevatesoft.com
Image