Subject Re: [IBO] Change ORDER changer to desc in OnPrepareSQL
Author Helen Borrie
At 01:00 AM 10/02/2005 +0100, you wrote:

>I use OnPrepareSQL to modify the sqlwhereitems as descibed in the
>Online help. That's working good.
>But how do I invert the given order on the defined oderitems, which
>contains concatenated fields (for example custumername+PK)?
>example:defined in OrderItems "customername=name,ref"
>normal ascending mode is resulting in : ... ORDER by name,ref
>wanted additional descending mode: ... ORDER by name desc, ref
>An idea is of course to add additional oderitems, but maybe there is
>another way to do so?

The SQLOrder property is available in OnPrepareSQL (and not anywhere else):

with MyDataset do
SQLOrder.Add('name desc, ref');

Since OnPrepareSQL is the last place you can influence the query before it
is re-prepared, any SQLOrder entry will override the current OrderingItem
when preparing the dataset for re-opening. SQLOrder is useful if you want
to allow the user to define ad hoc orderings - which might perform badly if
set on unindexed or poorly indexed fields.

OrderingItems is really a more flexible way to condition the set ordering,
especially if you make the orderings available to the user for selection,
because it gives you the opportunity to pre-define orderings based on good