Subject Re: [IBO] IB_Query Ordering Problems
Author kj01135
Hmmm.., I saw this before on other thread. Does it have to use at
OnPrepareSQL event? Or It can be used at any place and refresh the
dataset automatically?

Based on what it said in GSG. I can use SQLOrder to add sorting
criteria at runtime. My code look like this:

procedure TDMItems.qryItemPrepareSQL(Sender: TIB_Statement);
begin
with qryItem do
begin
SQLOrder.Add('LOC_SHOP');
SQLOrder.Add('ITEMCODE');
end;
end;

qryItem's SQL is "select * from items;"

When I look at the SQL Monitor, it shows:

select * from items
LOC_SHOP;

which of course give an Invalid Token error as there is no Order By
in it. In the GSG example, it also use SQLWhereItems before
SQLOrder. So it makes me wonders whether SQLOrder can only be used
with SQLWhereItems. I am getting confuse.

Thanks for your help Paul.

Regards,
Kenneth Man

> The SQLWhereItems are a lot different from the other SQLxxx
properties.
>
> Properties like SQLOrder, SQLWhere, SQLHaving etc. contain the
entire
> clause including the keyword. So you have to set SQLOrder like
this:
>
> MyQuery.SQLOrder.Text := 'ORDER BY ARTNO, SIZE, PRICE';
>
> or in BCB (don't remember what you use, yesterday's messages on
other
> OS ;-)) :
>
> MyQuery->SQLOrder->Text = "ORDER BY ARTNO, SIZE, PRICE";
>
>
> HTH,
> Paul Vinkenoog