Help - what could cause this problem?
Posted: Thu 29 Mar 2007 10:50
Hello,
I am struggling with the following situation. I have a TIBCQuery component, quPosition, that accesses a table. I am performing this logic (Delphi 5, IBDAC 2.00, Firebird 2.01):
if quPosition.Locate('SYMBOL', pSymbol, []) then begin
... do something with existing record
end else begin
... insert a new record for this pSymbol value.
end;
Note that SYMBOL is the primary key on the table.
I am experiencing a problem that always occurs on the same pSymbol value, 'AHG'. This logic is called from a loop, repeatedly, for the same set of pSymbol values. The first time the logic is called for 'AHG', the locate succeeds, because there is already a record in the table for this value. The second time the logic is called with pSymbol = 'AHG', the Locate fails - even though the record still exists in the table! (no deletes are performed on this table at all). Then when the 'end else' branch is followed, the logic attempts to insert a new record for AHG and fails with 'violation of PRIMARY or UNIQUE KEY constraint'.
The strangest thing is that I can go into the Delphi debugger Evaluate/Modify window, do First on the quPosition component, and scroll through it, and I can actually see that there is a record there for SYMBOL = 'AHG'. What can possibly be causing this Locate to fail, when it has already succeeded once with the same record, and I can see that the record is there??
Thanks for any light you can shed. This is part of a very large project, I'm not sure I'll be able to duplicate the problem in a demonstration project. The query is attached to a TIBCTransaction object with ReadCommitted isolation level. i have experimented with various Refresh settings for the TIBCQuery, but so far this problem reoccurs no matter what I do. I have even done a complete backup and restore of the Firebird database - that didn't help either.
Thanks for any suggestions you can give. This appears to me to be a bug in the Locate logic - how can it be failing when the record is visibly there and can be seen by scrolling through the dataset with Next ???
I am struggling with the following situation. I have a TIBCQuery component, quPosition, that accesses a table. I am performing this logic (Delphi 5, IBDAC 2.00, Firebird 2.01):
if quPosition.Locate('SYMBOL', pSymbol, []) then begin
... do something with existing record
end else begin
... insert a new record for this pSymbol value.
end;
Note that SYMBOL is the primary key on the table.
I am experiencing a problem that always occurs on the same pSymbol value, 'AHG'. This logic is called from a loop, repeatedly, for the same set of pSymbol values. The first time the logic is called for 'AHG', the locate succeeds, because there is already a record in the table for this value. The second time the logic is called with pSymbol = 'AHG', the Locate fails - even though the record still exists in the table! (no deletes are performed on this table at all). Then when the 'end else' branch is followed, the logic attempts to insert a new record for AHG and fails with 'violation of PRIMARY or UNIQUE KEY constraint'.
The strangest thing is that I can go into the Delphi debugger Evaluate/Modify window, do First on the quPosition component, and scroll through it, and I can actually see that there is a record there for SYMBOL = 'AHG'. What can possibly be causing this Locate to fail, when it has already succeeded once with the same record, and I can see that the record is there??
Thanks for any light you can shed. This is part of a very large project, I'm not sure I'll be able to duplicate the problem in a demonstration project. The query is attached to a TIBCTransaction object with ReadCommitted isolation level. i have experimented with various Refresh settings for the TIBCQuery, but so far this problem reoccurs no matter what I do. I have even done a complete backup and restore of the Firebird database - that didn't help either.
Thanks for any suggestions you can give. This appears to me to be a bug in the Locate logic - how can it be failing when the record is visibly there and can be seen by scrolling through the dataset with Next ???