Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering count without cursor
Message
From
05/02/2009 08:58:49
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
05/02/2009 08:53:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01379421
Message ID:
01379438
Views:
16
How about a UDF that opens a table and closes it again? The following is not tested, but should give you the general idea:
* Note that in the following command, I omitted the alias.
? GetFilterCount("MyTable", "between(id,1583,1927) and state=='NY'")

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 lnCount
endfunc
>I want to avoid the 'use in cursor' (and to save typing).
>_TALLY its like reccount (I think that reccount is better) .
>Array takeing me to other typing and problems.
>Can I say to fox:
>ccount=getfiltercount("select distinct id from mytable;
> where between(mytable.id,1583,1927);
> and mytable.state=='NY'")
>thisform.txt.value=ccount
>
>
>function getfiltercount
> lparameters cquery
> &(cquery+' into cursor tmp1 nofilter')
> icount=reccount('tmp1')
> return transform (icount)
>endfunc
>
>
>
>>>Hi all,
>>>Can I run query and to retrive the rows count without cursor, or I must as following:
>>>
>>>local itotal
>>>select distinct id from mytable;
>>>	where between(mytable.id,1583,1927);
>>>	and mytable.state=='NY' into cursor mycursor nofilter
>>>itotal=reccount('mycursor')
>>>myform.txt1.value=transform(itotal)
>>>use in mycursor
>>
>>You could send the result to an array instead, and use ALEN() or _TALLY to see how many rows.
>>
>>Tamar
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform