Subject Re: [IBO] Re:TCDSProvider does not like TIBOQuery
Author Helen Borrie
At 04:00 PM 16/08/2010, you wrote:
>This following query generate error message ...Qry_xxx: Field 'Cust_Code' not
>found
>Select Curr_code, sum(AR_Amount)TotAmt
> From AccRcv
>Group Curr_code
>Having sum(AR_Amount) > 0

Somehow, you are providing the (wrong) information to the query about the key fields. If you supply Cust_Code as any sort of field name for a set that does not contain a field of that name, of course you can expect an error.

>if I include Cust_Code on the select list this will be okay,
>Select Cust_code, Curr_code, sum(AR_Amount) TotAmt
> From AccRcv
>Group Cust_code, Curr_code
>Having sum(AR_Amount) > 0
>
>However it is generate different result set which I do not want,
>because I want sum up the amount by Curr_code only
>instead of by Cust_Code, Curr_code

If you just want to get the totals for each currency then keep Cust_Code out of the query!

This one is fine (especially if you omit the typing errors):

>Select Curr_code, sum(AR_Amount) TotAmt
> From AccRcv
>Group by Curr_code
>Having sum(AR_Amount) > 0

The Keylinks for this set would be Curr_code, NOT the compound primary key of the underlying table.

You must start thinking about the *sets* that your applications work with, not tables. Your IBOQuery objects want to know which column[s] in the *set* to use to identify each row of the dataset uniquely.

>Thank you for your time and thought

No more from me, sorry: too many urgent things to do. My advice: do some more research and try to understand sets a bit better.

HB