Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Do This With A JOIN?
Message
From
29/12/2005 14:24:38
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01081733
Message ID:
01081767
Views:
13
Hi Kevin

In VFP 9 this works, but not in VFP8

UPDATE LineTemp ;
SET NumCleared = (select count(*) from Details where BoIDBase = LineTemp.BoIDBase and RecType = "A" and AirTime#" " and AirDate BETWEEN dStartDate and dEndDate)

>I have a header table, LineTemp, with is related into Details.
>
>For each LineTemp record, I want to do the code inside the DO WHILE loop
>for all of the Detail records.
>
>I want to do all of this more efficiently. I'm guessing there's a way to do
>this with a JOIN, but I'm not sure of the syntax.
>
>
>
>SELECT LineTemp
>SET RELATION TO BoIdBase INTO Details
>		
>** Loop once for each line item record
>SCAN
>
> ** Clear the number cleared counter
>  m.NumCleared = 0
>
>  ** Loop once for each detail record belonging to the
>  ** current line item
>  SELECT Details
>  DO WHILE BoIdBase = LineTemp.BoIdBase
>
>    ** If the record is active, and has an air time and falls in the
>    ** date range, then count it
>    IF Details.RecType = "A" AND;
>       NOT EMPTY(AirTime) AND ;
>       BETWEEN(AirDate, dStartDate ,dEndDate)
>			
>         ** Increment the number cleared variable		
>         m.NumCleared = m.NumCleared + 1
>
>    ENDIF
>
>    IF EOF()
>      EXIT
>    ELSE
>     SKIP 1
>    ENDIF
>
>  ENDDO
>
>  SELECT LineTemp
>  GATHER MEMVAR
>
>ENDSCAN
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform