Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering count without cursor
Message
From
05/02/2009 09:28:08
 
 
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:
01379451
Views:
15
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
>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
Thank you
Chaim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform