Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering count without cursor
Message
From
05/02/2009 09:13:22
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
05/02/2009 08:58:49
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01379421
Message ID:
01379443
Views:
18
Hi Himar,

if the filter is active, a simple COUNT should return the right _TALLY.

Agnes
>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
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform