Greetings,
We recently upgraded from 3.80 to 4.50(.0.36) and are experiencing issues with the order of returned queries.
I have traced the problem to the following example scenario:
A clean, newly created TClientDataset is populated from:
" SELECT LastName
FROM Customer
ORDER BY CustomerID, FirstName, LastName "
The DataSet comes back ordered by LastName (not CustomerID and FirstName first). On inspecting the DataSet, I see LastName was somehow added to the DataSet's .IndexFields, but .IndexFieldNames is blank. The dataset should have no explicit sorting - just retain SQL Server's query result record order.
Adding FirstName and CustomerID to the SELECT list 'resolves' the sorting issue. Unfortunately this is not a solution as we have many reports on many implementations.
Is there any way to turn off this behaviour? It worked fine on 3.80.
Please advise.
Thanks,
Carl
Problem with derived sort order
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
Hi Challenger,
Thanks for the reply, but poRetainServerOrder is not one of the options in Delphi 5... Here is the complete option set:
TProviderOption = (poFetchBlobsOnDemand, poFetchDetailsOnDemand,
poIncFieldProps, poCascadeDeletes, poCascadeUpdates, poReadOnly,
poAllowMultiRecordUpdates, poDisableInserts, poDisableEdits,
poDisableDeletes, poNoReset, poAutoRefresh, poPropogateChanges,
poAllowCommandText);
Regards,
Carl
Thanks for the reply, but poRetainServerOrder is not one of the options in Delphi 5... Here is the complete option set:
TProviderOption = (poFetchBlobsOnDemand, poFetchDetailsOnDemand,
poIncFieldProps, poCascadeDeletes, poCascadeUpdates, poReadOnly,
poAllowMultiRecordUpdates, poDisableInserts, poDisableEdits,
poDisableDeletes, poNoReset, poAutoRefresh, poPropogateChanges,
poAllowCommandText);
Regards,
Carl
This problem arises because in SDAC version 4 the TCustomDADataSet.PSGetDefaultOrder method was added, that returns a list of index fields. This behaviour is coordinated with standatd BDE components. If TCustomDADataSet.PSGetDefaultOrder returns all fields that are included in ORDER BY list and not included in SELECT list, than the TClientDataSet component raises an error when trying to find a non-existent field in the fields list.
In order to solve the problem with sorting you should add in SELECT clause all fields included in ORDER BY clause. You can exclude unused fields in the fields list of TClientDataSet.
Also if you have the source code of SDAC you can redo the TCustomDADataSet.PSGetDefaultOrder method that will return nil.
In order to solve the problem with sorting you should add in SELECT clause all fields included in ORDER BY clause. You can exclude unused fields in the fields list of TClientDataSet.
Also if you have the source code of SDAC you can redo the TCustomDADataSet.PSGetDefaultOrder method that will return nil.