Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy a Cursor and its indexes
Message
De
15/06/2006 21:49:46
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01129043
Message ID:
01129434
Vues:
12
This message has been marked as the solution to the initial question of the thread.
Hi Brenda,

>I want to also copy the index on the cursor to the new cursor. How can I find out what is the current index?

Look at ATAGINFO() to get the index info about a cursor. Use ORDER() to find out the name of the index tag that is the current index tag. Put it all together with SELECT into CURSOR READWRITE and you have a solution.
* assume you have a cursor "foocur" with or without index tags
SELECT foocur
* get current tagname (empty string if none)
lcCurrentTagName = ORDER("foocur")
* get array of tag/expression info (no array created if none)
ATAGINFO(aMyIndexes, "", "foocur")

* now select into your new cursor
SELECT * FROM foocur INTO CURSOR foocur2 readwrite

* if we got an array with at least one row, index the new cursor
* and set the order to match the original cursor
* NOTE: VFP9 is required for the new second param on TYPE() to work
IF TYPE("aMyIndexes",1) = "A" AND ALEN(aMyIndexes, 1) > 0

  FOR lnLoop = 1 TO ALEN(aMyIndexes, 1)
    * 3=expression, 1=tagname, 5=ascending/descending, 4=filter
    lcCmd = "INDEX ON " + aMyIndexes[lnLoop, 3] + " TAG " + ;
            aMyIndexes[lnLoop, 1] + " " + ;
            aMyIndexes[lnLoop, 5]
 
    * NOTE: If you have FOR expressions on your indexes
    * you need to add that onto the lcCmd by using info in the
    * 4th column of the array

    * execute the command
    &lcCmd
  ENDFOR

  IF NOT EMPTY(lcCurrentTagName)
    SET ORDER TO TAG (lcCurrentTagName)
  ENDIF

ENDIF
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform