Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simplify 2 selects
Message
 
To
19/01/2007 13:51:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01187112
Message ID:
01187122
Views:
23
>Anybody know if the following code could be simplified?
>
>select dist site_id from training into cursor crstemp
>select dist reccount() as sitesrepresented from crstemp into array aSitesRepresented
>
>
>The need is to get a single number that will be used in a report. The above works and the array appears to be global, but I was not overly comfortable with the solution.
>
>Thanks

Why not just use site_id as such a number? As far as I see you have DISTINCT site_id? so it can't be duplicate.
Also I hate ot have functions like RECNO(), RECCOUNT() and other is SELECT, I don't know when I must add an additioanl table in that select and the whole logic goes to hell (if it is based on these functions).

UPDATE. After I read the Edward post I realize what you want :-)
You don't need the second select at all, you have 2 choices:
* 1. 
select dist site_id from training into cursor crstemp
lnRecCount = RECCOUNT()

2. (Edward suggesion)
lnRecCount = _TALLY
Then use lnRecCount in report.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform