Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select with wildcards
Message
 
 
To
29/06/2009 16:22:48
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01409173
Message ID:
01409196
Views:
59
>>>Is it possible to construct a SELECT where the fields are identified with wildcards? Something like
>>>
>>>
>>>SELECT p* FROM allcounts
>>>
>>>
>>>The object being to get only the fields that begin with the letter "p". This would save me from individually typing out all 200 of them.
>>>Thanks
>>
>>
>>nFcount=fcount('allcounts')
>>cFieldstring=''
>>For nLoop=1 to nFcount
>>  If Upper(Left(field(nLoop,'allcounts'),1))=='P'
>>    cFieldstring=cFieldstring+" + " + field(nLoop,'allcounts')
>>  Endif
>>Endfor
>>If Empty(cFieldstring)
>>  =messagebox("No Qualified Fields Found!")
>>  Return
>>Endif
>>cFieldstring=left(cFieldstring,len(cFieldstring)-1)
>>SELECT &cFieldstring. FROM allcounts
>>
>
>Thanks Ed. That was quite helpful. Thanks also to Naomi and Sergey.
>The objective was a stored procedure to return the sum of fields p1-p96. Here's my finished code.
>
>procedure GetD1Total
>	lparameters iCountID,iDay
>	cFields = ""
>	for i = 1 to 96
>		cFields = cFields + "p" + alltrim(str(i)) + ","
>	next
>	cFields = left(cFields, len(cFields)-1)
>	
>	select &cFields from allcounts where count_id = iCountID and _day = iDay into array A1
>	RetVal = 0
>	for i = 1 to 96
>	RetVal = RetVal + A1(i)
>	next
>	close tables all
>	return RetVal
>
May be you could have created one field as

p1 + p2 + p3 ... etc as SumP (to eliminate the second loop)?
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform