Page 1 of 1

A problem with the new IndexFieldNames / SortedFields

Posted: 06.11.2006, 14:57
by gto
Hello there!
I was building an program that uses zeos with the latest version due to some changes that costumer asked to me and one simple problem pop up:

I know that IndexFieldNames was changed some time ago. It doesn't matter to me, as I don't use it. But in this old program (that was converted from BDE, and used IndexFieldNames in the past), I may forgot some IndexFieldNames filled up. Doesn't matter too, becouse I've never had any problems. But with the new version, there is a problem. The IndexFieldNames was self completed with an 'Asc' (from Ascending) after the fields definitions, and, the big problem, a while not query.eof construction became an infinite loop. Removed the IndexFieldNames property (leave it blank) and everything works again.

Look to me that every time that the ZQuery Recevied the .Next command, it tries to reorder the data, and take the position of cursor to BOF (the first record), as my loop always stop in the second row.

Anyone with the same problem? It's not a * problem * at all, as I've resolved it removing the property values. But may become a problem for anyone that may use it.

[]'s

Posted: 07.11.2006, 02:08
by bangfauzan
Hi, gto

The purpose of the new IndexFieldNames is for sorting only, as combination of the new behavior of SortedFieldNames and SortType.

If u converted from BDE that use IndexFieldNames, you now can use LinkedFields (as master detail relationship). LinkedFields has the same behavior as old IndexFieldNames.

Conclusion:
- the old IndexFieldNames was replaced by LinkedFields, so LinkedFields is similar (or equal) with IndexFieldNames in other standard components.
- the new IndexFieldNames is another way in performing order.

Regards

Fauzan

Posted: 07.11.2006, 08:51
by mdaems
Hi Fauzan,

I think you missed the major problem gto wants to tell us. Is it right that every call to next can trigger a reorder and an infinite loop when you 'next till eof'?
Maybe you can exchange some examples with gto?

Mark

Re: A problem with the new IndexFieldNames / SortedFields

Posted: 07.11.2006, 11:03
by bangfauzan
gto wrote:and, the big problem, a while not query.eof construction became an infinite loop.
I used this component (6.6.0 beta) in production environment, and everythink ok. Here an example based on your cases. Using Mysql 5 I also attach the database script (contoh.sql). No problem at all.

can u send me the example of your cases please?

regards

Fauzan

Posted: 07.11.2006, 16:49
by gto
That's right, the demo from bangfauzan works ok. I cannot post a demo becouse it was part of a big project, and it should be a isolated problem. Thanks anyway :)

Sort 2 fields

Posted: 08.11.2006, 04:05
by cipto_kh
What about if I want to sort that base on 2 fields, the one is sort asc and the other desc. How to make it work? I mean by using that new property (not using SQL query)

TIA
bangfauzan wrote:Hi, gto

The purpose of the new IndexFieldNames is for sorting only, as combination of the new behavior of SortedFieldNames and SortType.

If u converted from BDE that use IndexFieldNames, you now can use LinkedFields (as master detail relationship). LinkedFields has the same behavior as old IndexFieldNames.

Conclusion:
- the old IndexFieldNames was replaced by LinkedFields, so LinkedFields is similar (or equal) with IndexFieldNames in other standard components.
- the new IndexFieldNames is another way in performing order.

Regards

Fauzan

Posted: 09.11.2006, 07:57
by bangfauzan
As far as I know, currently the property able only sorting one or more fields in one order method (asc only or desc only).
If you want to sort 2 fields in different order, the only way is by sql script.

regards.