Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sorting/Indexing a Buffered Cursor
Message
De
28/01/2006 18:25:36
 
 
À
28/01/2006 16:43:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01091159
Message ID:
01091219
Vues:
11
>>>Hi!
>>>
>>>I have a grid class which allows users to sort any column (asc or desc) by clicking on it. Internally it creates an index on the fly and handles row/table buffering etc.
>>>
>>>All this works fine but how do I handle sorting/indexing columns in a table buffered cursor with modified rows (uncommitted changes)?
>>>
>>>The users do not want to save the changes first but add, change data, sort on different columns, have a look at the data and then decide if they want to save the changes or not.
>>>
>>>I would prefer not to create an index on every column in the table as there are many columns.
>>>
>>>Sarosh
>>
>>this is a dynamic column index with table buffer support,
>>the only issue is the public variable
>>
>>CREATE CURSOR dynindex (f1 i,f2 i)
>>FOR k=1 TO 100
>> INSERT INTO dynindex VALUES (RAND()*10000,RAND()*10000)
>>NEXT
>>g_indexexp = ".T."
>>INDEX ON EVAL(m.g_indexexp) TAG TCOLUMN
>>CURSORSETPROP("Buffering",5)
>>BROWSE NORMAL
>>g_indexexp = FIELD(1)
>>REINDEX
>>BROWSE NORMAL
>>g_indexexp = FIELD(2)
>>REINDEX
>>BROWSE NORMAL
>>
>
>
>Fabio, I just tryed this and on REINDEX I get an error message:
>"Command cannot be issued on a Table with Cursors in Table Buffering mode". Just change some values when first browse appears.

You are right, I had forgotten of the REINDEX bug ( it has to also produce an error without changes )

This is another way using a special field,
but it is a static sort only:
CREATE CURSOR dynindex (SORT I,f1 i,f2 c(10))
FOR k=1 TO 100
 INSERT INTO dynindex VALUES (0,RAND()*10000,TRANSFORM(RAND()*10000))
NEXT 

INDEX ON SORT  TAG t1

CURSORSETPROP("Buffering",5)

BROWSE NORMAL

* index on F1
SELECT RECNO() rno FROM dynindex WITH (BUFFERING = .T.) ORDER BY F1 INTO CURSOR sortColumn
SET ORDER TO 0 IN dynindex
SET RELATION TO rno INTO dynindex
REPLACE ALL dynindex.sort  WITH RECNO()
USE

SELECT dynindex 
SET ORDER TO 1
LOCATE
BROWSE NORMAL

* index on F2
SELECT RECNO() rno FROM dynindex WITH (BUFFERING = .T.) ORDER BY F2 INTO CURSOR sortColumn
SET ORDER TO 0 IN dynindex
SET RELATION TO rno INTO dynindex
REPLACE ALL dynindex.sort WITH RECNO()
USE

SELECT dynindex
SET ORDER TO 1
LOCATE
BROWSE NORMAL
It is possible to build a dynamic order without the field Sort,
but it is more complex.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform