Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine relative record position
Message
De
27/10/1998 10:58:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00149770
Message ID:
00151003
Vues:
31
>>>>>>I'm selecting two records in a table so I can copy or delete all the records between each of the selected record. My problem comes when the table is indexed. Is there a way to do this? I'm having a problem determining if the second record is before or after the first record. I'm using 5.0a. TIA
>>>>>
lcKey = key()
>>>>>* On one of recs
>>>>>luValue1 = eval(lcKey)
>>>>>go nOtherRec
>>>>>luValue2 = eval(lcKey)
>>>>>select * from mytabel ;
>>>>>  where &lcKey between ;
>>>>>  min(luValue1,luValue2) ;
>>>>>  and  max(luValue1,luValue2)
Cetin
>>>>
>>>>Worked like a charm Cetin. I also needed to update a field using the condition so I replaced the SELECT statement with a REPLACE statement and it does just what I needed. Thanks again...
>>>
>>>Glad to be helpfull :) As a reminder, while "select" part could be replaced by endless :) solutions of FP, select also supports a "set field1 = newvalue..." as an alternative to "replace".
>>>Cetin
>>
>>I ran into little problem. The procedure works great when all the records are unique in the index key. If the last record I select has multiple records with the same key past it, it selects those records also. Don't know if you have run into this before. Any suggestion would help. Thanks again.
>
>I answered my own question. I added the RECNO() to each of the indexes to create a unique condition. Thanks again....
Hi Brad,
I would suggest a similar thing. But instead of adding recno() to indexes you could make the routine more generic :
lcKey = key()
* On one of recs
luValue1 = eval(lcKey)
lnRec1 = recno()
go nOtherRec
luValue2 = eval(lcKey)
lnRec2 = recno()
=seek(iif(luValue1 <= luValue2,luValue1, luValue2)) && Seek first one
lnFirstRec = iif(luValue1 <= luValue2,lnRec1, lnRec2)
scan while recno() # lnFirstRec && Locate start point
endscan
lnLastRec = iif(luValue1 <= luValue2,lnRec2, lnRec1)
luEnd = iif(luValue1 <= luValue2,luValue2, luValue1)
scan while eval(lcKey) <= luEnd
   if eval(lcKey) = luEnd ;
      and lnLastRec = recno()  && Hit last in range
      =doprocess()
      exit
   endif
   =doprocess()
endscan
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform