Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Filtering count without cursor
Message
De
05/02/2009 12:28:16
 
 
À
05/02/2009 09:28:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01379421
Message ID:
01379548
Vues:
19
>Excellent!
>Can you take a look on the following?
>
ccount=getfiltercount("mytable", "between(id,521548,529785)")
>thisform.txt1.value=ccount
>
>function getfiltercount(tctable, tcfiltercondition)
>	local lnselect, lncount
>	lnselect = select() && Save current work alias!
>	select 0
>	use (tctable) again
>	count for &tcfiltercondition
>	lncount = _tally
>	use
>	select(lnselect)
>	return (transform(lncount))
>endfunc
>
>

Update: Realized there might be problems if (tcTable) is actually a cursor or in an open database that wouldn't be active when you change the datasession

Here's another approach
FUNCTION getfiltercount(tctable, tcfiltercondition)
    LOCAL oData
    LOCAL ARRAY aResult[1]
    oData = CREATEOBJECT("session")
    SET DATASESSION TO oData.datasessionid
    SELECT COUNT(*) FROM (tcTable) WHERE &tcFilterCondition INTO ARRAY aResult
    oData = .NULL.
    RETURN TRANSFORM(aResult)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform