Subject Re: TIBOQuery + TClientDataSet = EDatabaseError
Author DanyM
--- In IBObjects@yahoogroups.com, "kokok_kokok" <kokok_kokok@...> wrote:
>
>
> I need to use a TClientDataSet + TDataSetProvider. I tie the TDataSetProvider with a TIBOQuery.
>
> It works fine, but when I do not use the primary key in the SELECT clause, a EDatabaseError is raised by TIBOQuery.
>
> This problem is widely managed in
> http://tech.groups.yahoo.com/group/IBObjects/message/44737
> and other posts, but until know, I have not found the solution.
>
> In some case, I do not need/want to add the primary key value in the SQL. For example:
>
> SELECT SUM(Amount) AS Total FROM Orders
>
> other case that fails:
>
> SELECT ID AS OrderID, Name FROM Orders
>
> I have tried to use KeyLinks but it continues failing. It seems that IBO calculates the primary key and then it tries to use it, but since it is not in the SELECT clause, a Field Not Found error is raised.
>
> Any help will be welcome. Thank you
>

I moved from TClientDataSet to kbmMemTable and this problem went away. My suspicion at the time was that the TClientDataSet was asking IBO for irrelevant stuff because IBO provides information on indices from the metadata cache. The TClientDataset uses fieldDefs and Field in a curious way* when loading off of a TDataSource. What I did was simply to gobble the exception, but if you do not have the sources that might prove a bit shaky. You'll need to ascertain that the try-except does not catch any other exception you might want propagated lower down the call stack.

HTH,

/Dany

* Hmm... that is more a guess and an opinion that anything else.